简体   繁体   中英

How to write in new line in file in Python

I have a file that is like this:

word, number
word, number
[...]

You can just use f.write(str(word)+"\\n")<\/code> to do this. Here str<\/code> is used to make sure we can add "\\n".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM