Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Cách mở file append mode Python?


Mở file append mode, chỉ định 'a' (a=append).

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

Mở my_file.txt append mode, thêm "Hello World" cuối file.