读取文件的数据默认为string,接口需要bytes
转换
data=bytes(value,'utf8')
定义对象
values='{"diastolic": "76", "pulse": "62", "measureWay": "2", "testTime": "2016-09-27 19:36:07", "town": "310116503000", "systolic": "103", "personCard": "4XX98XXX9010XXXXX8"}'
查看类型
print(type(values))
输出结果
定义对象
values={"diastolic": "76", "pulse": "62", "measureWay": "2", "testTime": "2016-09-27 19:36:07", "town": "310116503000", "systolic": "103", "personCard": "4XXXXXXXXXXXXXXXXXXXXXXX8"}
查看类型,输出结果
dict转str
data=json.dumps(values)
str转bytes
data=bytes(data,'utf8')