字符串This quo\"te String在正常的Python中需要两个转义:一个用于\,一个用于",总共做三个反斜杠: >>> print("This quo\\\"te String")This quo\"te String 对于json,所有这些反斜杠本身都必须转义,因为该字符串嵌入到另一个字符串中。因此,总共需要六个反斜杠: >>> print(json.loads('"This quo\\\\\\"te String"'))This quo\"te String 但是,如果使用raw-strings,则不需要额外的逃逸: >>> print(json.loads(r'"This quo\\\"te String"'))This quo\"te String 在第一个示例中,四个反斜杠将被解析为单个文本\(即作为转义反斜杠),而"将不被转义。 请注意,如果字符串位于dict内,则没有区别——结果将完全相同: >>> dct = json.loads('{"Testing": "This quo\\\\\\"te String"}')>>> print(dct['Testing'])This quo\"te String