python get json via reg

    def test_extract_json(self):
        text = '{"a":"aaa","b":2}'
        prop = 'a'

        reg = f'"{prop}"' + r':["]?(.*?)["?|}|,]'
        print(reg)

        match = re.findall(reg, text)[0]
        print(match)

猜你喜欢

转载自www.cnblogs.com/kevin1988/p/11668089.html
今日推荐