标签:
import json
str1 = "[11,22,33,44]"
li = json.loads(str1)
print (type(li))
print (li)
str2 = ‘{"k1":"v1","k2":"v2"}‘
dic = json.loads(str2)
print (type(dic))
print (dic)
结果:
<class ‘list‘>
[11, 22, 33, 44]
<class ‘dict‘>
{‘k2‘: ‘v2‘, ‘k1‘: ‘v1‘}
结论:json可以将字符串格式化为相应的数据类型
标签:
原文地址:http://www.cnblogs.com/python-study/p/5456461.html