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


猜你喜欢

转载自blog.csdn.net/zn505119020/article/details/78950620
今日推荐