1.json.dumps和 json.loads的區(qū)別:
json.dumps : dict轉(zhuǎn)成str
json.loads: str轉(zhuǎn)成dict
2.eval()函數(shù)十分強(qiáng)大,
將string類型的list轉(zhuǎn)換成list
a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]"
b = eval(a)
print type(b)
print b
將string類型的dict轉(zhuǎn)換成dictc = "{1: 'a', 2: 'b'}"
d = eval(c)
print type(d)
print d
將string類型的tuple轉(zhuǎn)換成tuple
e = "([1,2], [3,4], [5,6], [7,8], (9,0))"
f = eval(e)
print type(f)
print f