我想从文本文件中随机检索并打印一整行。
文本文件基本上是一个列表,因此需要搜索该列表中的每个项目。
import random
a= random.random
prefix = ["CYBER-", "up-", "down-", "joy-"]
suprafix = ["with", "in", "by", "who", "thus", "what"]
suffix = ["boy", "girl", "bread", "hippy", "box", "christ"]
print (random.choice(prefix), random.choice(suprafix), random.choice(prefix), random.choice(suffix))
这是我的代码,如果我只是手动将其输入到列表中,但我似乎无法找到如何使用数组或索引逐行捕获文本并使用它