fileObject.write(string)
\n 是換行符號。
[dywang@deyu zzz]$ cat fileio3.py
#!/usr/bin/python3
# coding: utf-8
fo = open("fileio.txt", "ab+")
fo.write("Python 是很棒的程式語言。\n是的,確實很棒!!\n".encode())
fo.close()
[dywang@deyu zzz]$ ./fileio3.py [dywang@deyu zzz]$ cat fileio.txt Python 是很棒的程式語言。 是的,確實很棒!! [dywang@deyu zzz]$ ll fileio.txt -rw-rw-r--. 1 dywang dywang 59 Dec 23 14:26 fileio.txt