2016-11-12 120 views

回答

1

您可以使用open,然後將生成的文件處理程序的write方法。

import itertools 
res = itertools.product('qwertyuiopasdfghjklzxcvbnm', repeat=3) 

with open('output.txt', 'w') as f: 
    for group in res: 
     word = ''.join(group) 
     f.write(word+'\n') 
     print(word) 
+0

感謝它的工作。 –

相關問題