📜  随机播放文本行 python 代码示例

📅  最后修改于: 2022-03-11 14:45:45.567000             🧑  作者: Mango

代码示例1
import random
with open('the_file','r') as source:
    data = [ (random.random(), line) for line in source ]
data.sort()
with open('another_file','w') as target:
    for _, line in data:
        target.write( line )