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