Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python';s请求邮件未发送_Python_Post_Python Requests - Fatal编程技术网

python';s请求邮件未发送

python';s请求邮件未发送,python,post,python-requests,Python,Post,Python Requests,我一直在尝试通过python代码向deep dream网站发布一个图像文件,但每次尝试,我都会返回到主主页。我对该请求的post方法仍然不熟悉,但经过几个小时的搜索,我似乎不知道出了什么问题 以下是我尝试过的代码: import requests url = 'http://psychic-vr-lab.com/deepdream/' files = {'imagefile': open('test.jpg', 'rb')} print("sending file to "+url) r =

我一直在尝试通过python代码向deep dream网站发布一个图像文件,但每次尝试,我都会返回到主主页。我对该请求的post方法仍然不熟悉,但经过几个小时的搜索,我似乎不知道出了什么问题

以下是我尝试过的代码:

import requests


url = 'http://psychic-vr-lab.com/deepdream/'
files = {'imagefile': open('test.jpg', 'rb')}
print("sending file to "+url)
r = requests.post(url, files=files)
print(r.text)
这是我在浏览器中尝试时的有效负载

------WebKitFormBoundaryVe3sVw1pN61EAIZ3
Content-Disposition: form-data; name="imagefile"; filename="test.jpeg"
Content-Type: image/jpeg


------WebKitFormBoundaryVe3sVw1pN61EAIZ3
Content-Disposition: form-data; name="MAX_FILE_SIZE"

5000000
------WebKitFormBoundaryVe3sVw1pN61EAIZ3--

任何对理解的帮助都将是巨大的

一,<代码>URL应为空。2.您应该指定文件的完整路径,而不仅仅是它的名称。我在前面尝试过,它确实会发送一条错误消息,说“文件类型需要是jpg。”尽管它是jpg。我怀疑给出完整路径是否会修复为给出无效路径的问题,比如tests.jpg抛出异常。