Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีเปิดไฟล์ใน Append Mode ด้วย Python

ระบุ mode 'a' สำหรับ append:

f = open('my_file.txt', 'a')
file_content = f.read()
f.write('Hello World')
f.close()

เพิ่ม "Hello World" ท้ายไฟล์