0
私がしたいことは、このプログラムの出力をテキストファイルに保存することです。出力をテキストファイルに保存するにはどうしたらいいですか?
import itertools
res = itertools.product('qwertyuiopasdfghjklzxcvbnm', repeat=3)
for i in res:
print ''.join(i)
イム走行のpython 2.7
私がしたいことは、このプログラムの出力をテキストファイルに保存することです。出力をテキストファイルに保存するにはどうしたらいいですか?
import itertools
res = itertools.product('qwertyuiopasdfghjklzxcvbnm', repeat=3)
for i in res:
print ''.join(i)
イム走行のpython 2.7
あなたは結果のファイルハンドラの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)
ありがとうございました。 –