logo
Loading...

執行 >>> open('/dev/video0','rw')? 出現錯誤。加w 的問題? - Cupoy

Traceback (most recent call last): File "&qu...

執行 >>> open('/dev/video0','rw')? 出現錯誤。加w 的問題?

2020/12/20 下午 03:21
使用 Python 進行 WebCam 視訊擷取與輸出
yaws508
觀看數:37
回答數:2
收藏數:0

![image](http://kwassistfile.cupoy.com/000001767F024D270000000F6375706F795F72656C656173655155455354/1608093718103/large) Traceback (most recent call last): File "", line 1, in ValueError: must have exactly one of create/read/write/append mode

回答列表

  • 2020/12/21 下午 00:26
    Jeffrey
    贊同數:0
    不贊同數:0
    留言數:0

    Hi, 沒有辦法針對同一裝置同時讀寫, python 中文件打開操作的mode有: [r、rb、r+、rb+、w、wb、w+、wb+、a、ab、a+、ab+] 有兩種方式: 方法一: with open('./device/video0', 'w') as vd: vd.write('.......') with open('file.txt', 'r+') as vd: # The mode is r+ instead of r print(vd.read()) 方法二: with open('./device/video0','rt') as vd: # Use file to refer to the file object with open('vd','wt') as vd_out:

  • 2020/12/21 下午 03:37
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:0

    嗨,你好
    我的印象也是不會把 rw 寫在一起,你是從哪裡看到這樣的寫法呢? 分享我自己的記法,主要有三種模式(一次只能用一個): * a: appdend,會由原本的資料繼續往下加 * w: write,每次都會把前面的清空重新寫入 * r: read,讀取資料 如果有 + 的話表示,若本來沒有檔案會建立一個新檔案; b 代表是二進位(binary)像是圖片。

    嗨,你好,我是維元,持續在不同的平台發表對 #資料科學、 #網頁開發 或 #軟體職涯 相關的文章。如果對於內文有疑問都歡迎與我們進一步的交流,都可以追蹤我的 Facebook技術部落格 ,也會不定時的舉辦分享活動,一起來玩玩吧 ヽ(●´∀`●)ノ