我正在做一個 python 腳本,它定期將文件夾上傳到 Google 云端硬盤,但是當我不得不加載子文件夾時卡住了。有沒有辦法上傳整個文件夾?也許有一個循環,但我不知道該怎么做。以下是要上傳的文件夾示例:root\
root\image.png
root\Folder1\text.txt
root\Folder1\music.mp3
root\Folder2\MyFolder\homeworks.txt
root\Folder2\Something\something.txt我正在使用 PyDrive。
1 回答

繁星coding
TA貢獻1797條經驗 獲得超4個贊
一個更簡單的解決方法是只壓縮文件:
shutil.make_archive('data', 'zip', 'output') file = drive.CreateFile({'title': 'data.zip'}) file.SetContentFile('data.zip') file.Upload()
添加回答
舉報
0/150
提交
取消