看板 Python 關於我們 聯絡資訊
想請問一下各位高手 我想寫一支複製一個影片檔(格式為mp4)的程式 程式碼如下: file1 = open("1.mp4", mode ='rb') file2 = open("2.mp4", "a") #另存一個新的檔案 tmp = '' while 1: tmp = file1.read(1024) if not tmp: break file2.write(tmp) file1.close() file2.close() 先讀取第一個1.mp4 再將這個影片複製一份為2.mp4 但2.mp4卻不能播放 且會莫名的比1.mp4多了幾百kb 請問是出了什麼問題呢? 對了,因為之後要去改mp4裡面的碼 所以不能用copyfile這個函式 謝謝 -- ▉╯╰ ▅▃▂ ▂ ╱ ╱ ╱ █ ╮╭ ▆▅ ▂▅▆ ╱ █ ╱ ╱ █ ╱ ▉ ◢▋ ▄▄ ▉ ◢▋ ╱ ████████████ ▉ ▆█◤ ▊ ▉ ▆█◤ ╱ ╱ █     ▋ ████████████   ▅▅ wretch@aqua -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.72.221 ※ 編輯: shwzu 來自: 140.116.72.221 (02/28 16:53) ※ 編輯: shwzu 來自: 140.116.72.221 (02/28 16:56)
doghib:試試看 file2 = open('2.mp4', 'ab') 改成二進 02/28 17:23
shwzu:啊 超感謝樓上 居然漏掉了 感謝感謝XD 02/28 17:26
yungyuc:shutil 02/28 20:11