小编Lal*_*ngh的帖子

如何解析字典字符串?

我试图将字符串转换为具有dict函数的字典,就像这样

import json
p = "{'id':'12589456'}"
d = dict(p)
print d['id']  
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误

ValueError: dictionary update sequence element #0 has length 1; 2 is required
Run Code Online (Sandbox Code Playgroud)

为什么会失败?我怎样才能解决这个问题?

python dictionary python-2.7

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

dictionary ×1

python ×1

python-2.7 ×1