json单引号 双引号问题

json 属性值用双引号

思路:     将单引号转换为 @#$

将双引号转换为^^&



def json_quote(string):
    singlequote = "@#$"
    doublequote = "^^&"
    string = str(string).replace("'",singlequote)
    string = str(string).replace('"',doublequote)
    string = str(string).replace(doublequote,"'")
    string = str(string).replace(singlequote,'"')
    return string



版权声明:本文为zn505119020原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。