Python 官方文档:入门教程 => 点击学习
文件 1 内容如下 #some Words Sometimes in life, You find a special friend; Someone who changes your life just
文件 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()
--结束END--
本文标题: python读文件
本文链接: https://lsjlt.com/news/185111.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0