eval函數(shù)就是實現(xiàn)list、dict、tuple與str之間的轉(zhuǎn)化
str函數(shù)把list,dict,tuple轉(zhuǎn)為為字符串
# 字符串轉(zhuǎn)換成列表
a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]"
print(type(a))
b = eval(a)
print(b)
# 字符串轉(zhuǎn)換成字典
a = "{1: 'a', 2: 'b'}"
print(type(a))
b = eval(a)
print(type(b))
print(b)
# 字符串轉(zhuǎn)換成元組
a = "([1,2], [3,4], [5,6], [7,8], (9,0))"
print(type(a))
b=eval(a)
print(type(b))
print(b)