簡體   English   中英

如何更改此設置以便用戶可以鍵入他們的目錄並消除字節錯誤?

[英]How can I change this so the user can type their directory and get rid of the byte error?

import zipfile

try:
    with zipfile.ZipFile("daysv2.zip") as file:
        file.extractall(pwd='abc123')
except Exception as e:
    print(e)
else:
    print("Extraction was successful")

如何更改此設置以便用戶可以鍵入他們的目錄和密碼? 另外我將如何解決這個錯誤

pwd: expected bytes, got str

pwd必須是一個bytes對象,它被寫入/指示,例如b'abc123' 或更籠統地說:

bytes('abc123', 'UTF-8') # For UTF-8 encoded string -> bytes

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM