One - One Code All

Blog Content

python判断字符串是否为合法的json格式

Python   2009-01-03 10:22:03

判断字符串是否合法的json格式。

可用于API接口返回数据的判断。

import json
 
def is_json(myjson):
    try:
        json.loads(myjson)
    except ValueError:
        return False
    return True



上一篇:python判断文件是否存在,不存在则创建
下一篇:PHP随机数函数rand()与mt_rand()的讲解

The minute you think of giving up, think of the reason why you held on so long.