Saving output in python -
this question has answer here:
- python print string text file 4 answers
i have code:
import itertools res = itertools.permutations('abcdefghijklmnopqrstuvwxyz',5) # 5 length of result. in res: print ''.join(i) i need result in stead of being printed print ''.join(i) saved in .txt file.
i not familiar python. thank time!
you can open file in write mode , use fileobject.write method write permutations file :
with open('file_name.txt','w') f: res = itertools.permutations('abcdefghijklmnopqrstuvwxyz',5) # 5 length of result. in res: f.write(''.join(i)+'\n')
Comments
Post a Comment