热线电话:13121318867

登录
2019-04-11 阅读量: 553
编写一个Python程序来读取文件中的随机行

import random 

def random_line(fname):

lines = open(fname).read().splitlines()

return random.choice(lines)

print(random_line('test.txt'))

0.0000
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子