文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>CDay−5/CDay−4(可爱的Python)

CDay−5/CDay−4(可爱的Python)

时间:2010-11-23  来源:Ray Z

CDay−4  1 >>> f = open("c:\\test.txt", 'r')
 2 >>> result = []
 3 >>> for line in f.readlines():
 4     line = line.strip()
 5     if not len(line) or line.startswith('#'):
 6         continue
 7     result.append(line)
 8 
 9     
10 >>> print result
11 ['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.', "when you're down,", 'and the world seems dark and empty,', 'Your forever friend lifts you up in spirits and makes that dark and empty', 'world', 'suddenly seem bright and full.', 'Your forever friend gets you through the hard times,the sad times,and the', 'confused times.', 'If you turn and walk away,', 'Your forever friend follows,', 'If you lose you way,', 'Your forever friend guides you and cheers you on.', 'Your forever friend holds your hand and tells you that everything is going', 'to be okay.']
12 >>> open('c:\\test.txt', 'w').write('%s' % '\n'.join(result))

 

 

相关阅读 更多 +
排行榜 更多 +
火柴人战争血腥打击

火柴人战争血腥打击

飞行射击 下载
沉浸式射击比赛

沉浸式射击比赛

飞行射击 下载
三角符文第一章下载

三角符文第一章下载

角色扮演 下载