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

วิธีเปิด Binary File ใน Append Mode ด้วย Python

Binary files = ไฟล์ที่ไม่ใช่ readable characters (รูป GIF, เสียง MP3, Word/PDF) เพิ่ม 'b' ใน mode สำหรับ binary append mode ใช้ 'ab':

ตัวอย่าง

f = open('my_file.mp3', 'ab')
file_content = f.read()
f.close()

เปิด binary append mode เก็บเนื้อหาใน file_content