【发布时间】:2020-10-10 21:53:14
【问题描述】:
我用 Python 编写了以下程序(使用 1000 个单词的文本文件并找到 4 个单词的所有排列)并在 Mac 终端上运行它:
from itertools import permutations
with open('wordlist.txt') as f:
content = f.readlines()
content = [x.rstrip() for x in content]
g = open("finalwordlist.txt", "a")
g.write('%s' % "\n".join(map("".join, permutations(content,4))))
过了一会儿,我从终端得到了以下输出:
Killed: 9
没有输出写入输出文本文件,所以我假设程序在 write() 步骤之前终止。
当我发现大小小于 4 的排列(例如 1、2、3)时,这个程序起作用了。被杀者:9 是因为所有排列的大小吗?还是和Mac终端环境有关?
我该如何解决这个错误?谢谢!
【问题讨论】:
标签: python macos terminal itertools