程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

The solution to the problem that Python crawlers report errors when parsing JSON without quotation marks for keys

編輯:Python

demjson-2.2.4

1. Recently, when parsing data, a Bug,

No nonsense, just look at the data

At that time, I saw json Format , I was very happy and thought it was direct json.loads() Soha will do , I didn't expect to report a mistake directly , Later, it was not standard json,key Without quotation marks at all ,

After some searching, we finally found a solution , The operation is as follows

pip3 install demjson

Then we can deal with it like this

import demjson
json_str = '{id: 1,lng: 104.08674,lat: 30.656809 ,title: " sichuan ( Taiguli store )",content: [" Address : Xia, Jinjiang District, Chengdu City, Sichuan Province ", " Telephone :12345678 "]}'
result = demjson.decode(json_str)
print(result)

notes , If the installation times the following error

Solution

pip install setuptools==57.5.0


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved