感谢指点,有request上传的时候报错说要解包的值太多[Python] 纯文本查看 复制代码 Traceback (most recent call last):
File "media.py", line 35, in <module>
myMedia.upload(accessToken, filePath, mediaType)
File "media.py", line 26, in upload
urlResp = requests.post(postUrl, files=openFile)
File "/usr/lib/python3/dist-packages/requests/api.py", line 116, in post
return request('post', url, data=data, json=json, **kwargs)
File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 519, in request
prep = self.prepare_request(req)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 452, in prepare_request
p.prepare(
File "/usr/lib/python3/dist-packages/requests/models.py", line 316, in prepare
self.prepare_body(data, files, json)
File "/usr/lib/python3/dist-packages/requests/models.py", line 504, in prepare_body
(body, content_type) = self._encode_files(files, data)
File "/usr/lib/python3/dist-packages/requests/models.py", line 141, in _encode_files
for (k, v) in files:
ValueError: too many values to unpack (expected 2)
第一个解决方法模块还是有问题,因为poster只支持python2,所以安装的是poster3,里边没有Form
[Python] 纯文本查看 复制代码 Traceback (most recent call last):
File "media.py", line 5, in <module>
from poster import Form
ModuleNotFoundError: No module named 'poster'
[Python] 纯文本查看 复制代码 Traceback (most recent call last):
File "media.py", line 5, in <module>
from poster3 import Form
ImportError: cannot import name 'Form' from 'poster3' (/usr/local/lib/python3.8/dist-packages/poster3/__init__.py)
非常感谢您的热心 |