基于 this 发布,使用 shuf 最快的方法是:
shuf
import sh sh.shuf("words.txt", out="shuffled_words.txt")
然而,这段代码也会洗牌标题。我的文件有一个头,我不想让头在数据中乱放。