我正在尝试转换从带有 urllib3 的 http 请求生成的字符串。
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
data = json.load(data)
File "C:\Python27\Lib\json\__init__.py", line 286, in load
return loads(fp.read(),
AttributeError: 'str' object has no attribute 'read'
>>> import urllib3
>>> import json
>>> request = #urllib3.request(method, url, fields=parameters)
>>> data = request.data
现在...尝试以下操作时,我收到该错误...
>>> json.load(data) # generates the error
>>> json.load(request.read()) # generates the error
跑步type(data)
并type(data.read())
返回<type 'str'>
data = '{"subscriber":"0"}}\n'