ระบุ mode 'w+' สำหรับ read/write (ทับไฟล์):
f = open('my_file.txt', 'w+')
file_content = f.read()
f.write('Hello World')
f.close()
อ่านได้ เขียนทับได้ ใช้ r+ แทนได้ (ไม่ truncate)
ระบุ mode 'w+' สำหรับ read/write (ทับไฟล์):
f = open('my_file.txt', 'w+')
file_content = f.read()
f.write('Hello World')
f.close()
อ่านได้ เขียนทับได้ ใช้ r+ แทนได้ (ไม่ truncate)