gpt4 book ai didi

python - python中使用POST上传文件。去哪里看?

转载 作者:太空宇宙 更新时间:2023-11-03 19:25:15 24 4
gpt4 key购买 nike

我想从该网站上传并获取结果。 http://cello.life.nctu.edu.tw/

我试过了

from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2

register_openers()

params = ({"file": open("xaa", "r"),
"seqtype": "prot",
"species": "eu"})
datagen, headers = multipart_encode(params)

request = urllib2.Request("http://cello.life.nctu.edu.tw/cgi/main.cgi", datagen, headers)
print urllib2.urlopen(request).read()

但我收到一个错误

  Traceback (most recent call last):
File "client.py", line 9, in <module>
a = opener.open("http://cello.life.nctu.edu.tw/cgi/main.cgi", params)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 400, in open
response = meth(req, response)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 513, in http_response
'http', request, response, code, msg, hdrs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 438, in error
return self._call_chain(*args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 372, in _call_chain
result = func(*args)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 521, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: Internal Server Error

我不知道这里出了什么问题。有人可以指点我一下吗。 ?谢谢。

顺便说一句。 xaa 文件看起来像这样 http://pastebin.com/7VK3vvwC

最佳答案

Error 500: Internal Server Error

这是服务器错误。换句话说,您的代码没有任何问题 - 只是此页面出现错误。

关于python - python中使用POST上传文件。去哪里看?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8381461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com