1.json.dumps和 json.loads的区别:
json.dumps : dict转成str
json.loads: str转成dict
2.eval()函数十分强大,
将string类型的list转换成list
a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]"
b = eval(a)
print type(b)
print b
将string类型的dict转换成dictc = "{1: 'a', 2: 'b'}"
d = eval(c)
print type(d)
print d
将string类型的tuple转换成tuple
e = "([1,2], [3,4], [5,6], [7,8], (9,0))"
f = eval(e)
print type(f)
print f
网友评论