如执行代码:
data = parse.urlencode(raw).encode(‘utf-8’)
request = urllib.request.Request(collectUserCoin_url, headers=headers, data=data)
response = urlopen(request)
返回如下信息:
{"code":"321","msg":"参数校验未通过:[must not be blank]","txId":"123213","data":null}
数据中包括null,对返回信息处理时代码报错:name ‘null’ is not defined
具体原因为:python无法处理null这样的字符串
字符串处理方式:
1、可将字符串中的null替换成‘’,即str.replace(null,‘’)
2、将null定义为变量,即:null=‘’,
3、直接将字符串处理:a=json.loads(a)