📜  我如何确保一行不会从 python 代码示例中的文件中重复

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

代码示例1
from random import sample

file_name = "text_database.txt"
lines = open(file_name, "r").read().splitlines()

for line in sample(lines, k=len(lines)):
    print(line)