test = '{"m":"shopitemsearch","vm":"nw","sversion":"4.6","shopId":106376474,"sellerId":1779881393,"style":"wf","page":1,"sort":"_sale","q":"","catmap":"","wirelessShopCategoryList":""}'
print(type(test))
print(eval(test))
print(type(eval(test)))
print(json.loads(test))
print(type(json.loads(test)))
得到的信息说明eval与json.loads对于双引号的数据都可以进行转换,但是
test = "test = "{'m':'shopitemsearch','vm':'nw','sversion':'4.6','shopId':106376474,'sellerId':1779881393,'style':'wf','page':1,'sort':'_sale','q':'','catmap':'','wirelessShopCategoryList':''}"
print(type(test))
print('eval',eval(test))
print(type(eval(test)))
print('json.loads',json.loads(test))
print(type(json.loads(test)))
可以看出来json.loads对于单引号内的数据无法进行转换,可以通过replace将所有的单引号转化为双引号进行使用,但是本人觉得使用eval将格式进行转换更加方便,具体的底层原理还不太清楚,如有不认同可以提出来,我们一起成长