急! python json解析问题 20
求问这一句到底哪里错了!!!importjsondata=json.loads('{"ID":"2","IP":"12.12.12.12","Port":"3000","...
求问 这一句 到底哪里错了!!!
import json
data= json.loads('{"ID": "2", "IP":"12.12.12.12", "Port": "3000", "Sensor_Count":"1", "Control_Count": "1", "Sensors":{"Sensor_Name": "tem", "Type_Count": "1", "Types":{ "types":["temp","C"],"types":["hum","N"],}},"Controls":["LCD","Relay"] }')
错误显示:
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
data= json.loads('{"ID": "2", "IP":"12.12.12.12", "Port": "3000", "Sensor_Count":"1", "Control_Count": "1", "Sensors":{"Sensor_Name": "tem", "Type_Count": "1", "Types":{ "types":["temp","C"],"types":["hum","N"],}},"Controls":["LCD","Relay"] }')
File "D:\python2.7\lib\json\__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "D:\python2.7\lib\json\decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\python2.7\lib\json\decoder.py", line 381, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 194 (char 193) 展开
import json
data= json.loads('{"ID": "2", "IP":"12.12.12.12", "Port": "3000", "Sensor_Count":"1", "Control_Count": "1", "Sensors":{"Sensor_Name": "tem", "Type_Count": "1", "Types":{ "types":["temp","C"],"types":["hum","N"],}},"Controls":["LCD","Relay"] }')
错误显示:
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
data= json.loads('{"ID": "2", "IP":"12.12.12.12", "Port": "3000", "Sensor_Count":"1", "Control_Count": "1", "Sensors":{"Sensor_Name": "tem", "Type_Count": "1", "Types":{ "types":["temp","C"],"types":["hum","N"],}},"Controls":["LCD","Relay"] }')
File "D:\python2.7\lib\json\__init__.py", line 338, in loads
return _default_decoder.decode(s)
File "D:\python2.7\lib\json\decoder.py", line 365, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "D:\python2.7\lib\json\decoder.py", line 381, in raw_decode
obj, end = self.scan_once(s, idx)
ValueError: Expecting property name: line 1 column 194 (char 193) 展开
4个回答
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你好:
还像是编码的问题:
试下:加上utf-8.
还像是编码的问题:
试下:加上utf-8.
更多追问追答
追问
你是说 在里面加上utf-8么 ? 像是这样?
json.loads("utf-8", '{.....}')
追答
在import json的上面,
就是这个py文件的头部;
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询