我正在尝试使用Python遍历文件夹结构并将找到的每个文件上传到指定的文件夹。问题在于它上传了一个具有正确名称的文件,但没有内容,文件大小仅为10字节。
import dropbox, sys, os
try:
dbx = dropbox.Dropbox('some_access_token')
user = dbx.users_get_current_account()
except:
print ("Negative, Ghostrider")
sys.exit()
rootdir = os.getcwd()
print ("Attempting to upload...")
for subdir, dirs, files in os.walk(rootdir):
for file in files:
try:
dbx.files_upload("afolder",'/bfolder/' + file, mute=True)
print("Uploaded " + file)
except:
print("Failed to upload " + file)
print("Finished upload.")
dbx.files_upload("潜在标题:勇士队以微弱优势战胜骑士队的第五场比赛紧张刺激", '/cavs vs warriors/game 5/story.txt')
我假设第一个参数是上传文件的描述标签。 - Mike Resolif
的问题也让我来到了这个帖子,感谢 @Cyrbil 提供的示例。 - sgauri