考虑字符串
{"Key":"Value\nNewLine"}
在线 json linter 将此字符串视为有效字符串并解析它
但是Python代码:
json_str ='''{"Key":"Value\nNewLine"}'''
dict = json.loads(json_str)
失败。为什么?
最佳答案
因为 \n
是换行符,而不是反斜杠和 n。你想要:
json_str = r'''{"Key":"Value\nNewLine"}'''
关于python - Python 中的 JSON 处理和在线 JSON Linters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32751943/