python url格式转json

from urllib import parse
import json

def test():
    s=parse.unquote("%7B%22group%22%3A%22code%3ACS%20534%22%2C%22key%22%3A%22crn%3A14786%22%2C%22srcdb%22%3A%22202101%22%2C%22matched%22%3A%22crn%3A14786%22%7D")
    b = json.loads(s)
    print(s)
    print(b)
    print()
test()
{"group":"code:CS 534","key":"crn:14786","srcdb":"202101","matched":"crn:14786"}
{'matched': 'crn:14786', 'group': 'code:CS 534', 'key': 'crn:14786', 'srcdb': '202101'}

 

你可能感兴趣的:(python url格式转json)