我试图通过 Strava API 上传多个文件。
在运行该uploadFitActivity()
方法时,它导致ValueError: too many values to unpack (expected 2)
我相信这个异常是由我的方法引发的uploadFitActivity()
,可能与f = {'file' : fitfile}
循环for
有关。但我无法弄清楚实际问题以及异常指向什么。
下面是我的uploadFitActivity()
方法:
def uploadFitActivity(dirpath, access_token):
uploads_url = "https://www.strava.com/api/v3/uploads"
payload = {
'client_id': client_ID,
'data_type': 'fit' }
header = {'Authorization': 'Bearer ' + access_token}
os.chdir(dirpath)
for filename in glob.glob("*.fit"):
with open(filename, 'rb') as fitfile:
f = {'file' : fitfile}
res = requests.post( uploads_url,
data = payload,
headers = header,
files = f )