Saving output in python -


this question has answer here:

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

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -