Single vs double quotes in JSON(JSON中的单引号和双引号)
问题描述
我的代码:
import simplejson as json
s = "{'username':'dfdsfdsf'}" #1
#s = '{"username":"dfdsfdsf"}' #2
j = json.loads(s)
#1
定义错误
#2
定义是对的
听说在 Python 中 single 和 double 引号可以互换.谁能给我解释一下?
I heard that in Python that single and double quote can be interchangable. Can anyone explain this to me?
推荐答案
JSON 语法 不是 Python 语法.JSON 的字符串需要双引号.
JSON syntax is not Python syntax. JSON requires double quotes for its strings.
这篇关于JSON中的单引号和双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!