conductor

[python] file write 본문

카테고리 없음

[python] file write

Hemos 2019. 11. 5. 23:45

여러가지

You can do this in two ways:

f.write("text to write\n")
// file.write(your_string + '\n')

or, depending on your Python version (2 or 3):

print >>f, "text to write" # Python 2.x
print("text to write", file=f) # Python 3.x

 

https://stackoverflow.com/questions/2918362/writing-string-to-a-file-on-a-new-line-every-time