文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>python读文件

python读文件

时间:2010-09-27  来源:jiaminqiang

文件 1 内容如下 

#some words
Sometimes in life,
You find a special friend;
Someone who changes your life just by being part of it.
Someone who makes you laugh until you can't stop;
Someone who makes you believe that there really is good in the world.
Someone who convinces you that there really is an unlocked door just waiting
for you to open it.

This is Forever Friendship.

 

使用读文件过滤空行和注释行

import re
file=open("1",'r')
a=file.readlines()
a.sort()
for  line in  a:
        if  re.match("^#",line):
                pass
        elif  re.match("^$",line):
                pass
        else:
                print line.strip()

相关阅读 更多 +
排行榜 更多 +
扑击萌兽大逃亡手游下载

扑击萌兽大逃亡手游下载

休闲益智 下载
gate交易平台app免费版

gate交易平台app免费版

金融理财 下载
Uniswap中文版app安卓版

Uniswap中文版app安卓版

金融理财 下载