Phạm Thanh Nam
New member
How do I write a list to a file?
Answer
Python – How to write a list to a file?
Answer
Python – How to write a list to a file?
- Using write method: #!/usr/bin/python l1=[‘hi’,’hello’,’welcome’] f=open(‘f1.txt’,’w’) for ele in l1: f.write(ele+’n’) f.close() …
- Using string join method: …
- Using string join along with with open syntax: …
- Using the writelines method: