python上传文件问题
python向asp的网站上传文件。。
代码如下:
url="xxx"        files = {'img_src': ( '1.jpg',filec,"application/octet-stream")}
        resp = req.post(url, files=files,verify=False)
        print resp.content
运行后发现asp提示错误500,文件并没有上传,对发送的数据包进行分析,发现
问题出在箭头所指的地方

成功上传

错误500 
也就是说成功长传的和错误500的少了两个--
但是我写的python代码默认是没有那两个--的,这个是可以自己定义的嘛?
回答:
我是一初学者,认为可以这样试试:
import requestsurl = "xxx"
headers = {
    'Cache-Control': "no-cache",
    'Content-Type':"binary",
    }
with open(filename, 'rb') as f:
    r = requests.post(url, data=f, headers=headers)
    print(r.text)
以上是 python上传文件问题 的全部内容, 来源链接: utcz.com/a/164236.html

