热线电话:13121318867

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


import random

def random_line(fname):

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

return random.choice(lines)

print(random_line('test.txt'))

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

发表评论

暂无数据
推荐帖子