Python post数据遇到httplib.BadStatusLine: ''问题求解,,源代码import ur
Python post数据遇到httplib.BadStatusLine: ''问题求解,,源代码import ur
源代码
import urllibimport urllib2url = 'http://pl.api.ledongli.cn/xq/io.ashx'values = {'action':'profile', 'pc':'andfa53e833c2f10a04456ecbb05789ca6', 'cmd':'updatedaily', 'uid':'29833686', 'list':[{"distance":233.65168,"duration":120.057373046875,"report":"[{\"calories\":0,\"distance\":0,\"duration\":120.057373046875,\"steps\":0,\"activity\":\"walking\"}]","calories":10.274937086736001,"steps":837,"pm2d5":0,"date":1437494400,"activeValue":7995}]}data = urllib.urlencode(values)header={'If-Modified-Since': 'Tue, 21 Jul 2015 23:58:52 GMT+00:00', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'User-Agent': 'Dalvik/1.6.0 (Linux; U; Android 4.4.4; HM NOTE 1S MIUI/V6.6.1.0.KHKCNCF)', 'Host': 'pl.api.ledongli.cn', 'Connection':'Keep-Alive', 'Accept-Encoding': 'gzip', 'Content-Length': '489'}req = urllib2.Request(url, data,headers=header)response = urllib2.urlopen(req)the_page = response.read()print the_page
报错
C:\Python27\python.exe E:/python/ledongliTraceback (most recent call last): File "E:/python/ledongli", line 18, in <module> response = urllib2.urlopen(req) File "C:\Python27\lib\urllib2.py", line 127, in urlopen return _opener.open(url, data, timeout) File "C:\Python27\lib\urllib2.py", line 404, in open response = self._open(req, data) File "C:\Python27\lib\urllib2.py", line 422, in _open '_open', req) File "C:\Python27\lib\urllib2.py", line 382, in _call_chain result = func(*args) File "C:\Python27\lib\urllib2.py", line 1214, in http_open return self.do_open(httplib.HTTPConnection, req) File "C:\Python27\lib\urllib2.py", line 1187, in do_open r = h.getresponse(buffering=True) File "C:\Python27\lib\httplib.py", line 1045, in getresponse response.begin() File "C:\Python27\lib\httplib.py", line 409, in begin version, status, reason = self._read_status() File "C:\Python27\lib\httplib.py", line 373, in _read_status raise BadStatusLine(line)httplib.BadStatusLine: ''Process finished with exit code 1
哪位大神帮忙看下
楼上的建议我的问题解决了, 点个赞
先把'Content-Length': '489' 去掉再看
编橙之家文章,
相关内容
- Python提取中文关键词方法,,我想从一组中文字符串中取
- python-rrdtool出现错误求解决MAC OS python pip install,python
- Python报错求助split method AttributeError不明白什么问题,
- Python GUI按键图标触发Python程序的操作问题,guipython,我
- Python支持用类实例作为List中元素吗,pythonlist,我把nba各
- Flask运行报错误不理解,flask不理解,代码只有一行topi
- Python 2.7版本中return输出格式疑问,python2.7,刚才那个代
- Python多线程提交插入数据库问题,python多线程,多线程读
- Python2.7 CGIHTTPServer OSError问题,,在windows上测试没
- Python re正则表达式替换字符,python正则表达式,python a
评论关闭