Role in Python eval function

eval function is to achieve mutual conversion list, dict, tuple with STR 
STR function to list, dict, tuple into a string

# String into a list of 
A = "[[1,2], [3,4-], [5,6], [7, 8], [9,0]]"
Print (type (A))
B = the eval (A)
Print (B)

# String into a dictionary 
A = "{. 1: 'A', 2: 'B'}"
Print (type (A))
B = the eval (A)
Print (type (B))
Print (B)

# String into a tuple 
A = "([1,2], [3,4-], [5,6], [7, 8], (9,0))"
Print (type (A))
B the eval = (A)
Print (type (B))
Print (B)

 

Guess you like

Origin www.cnblogs.com/chen-jun552/p/11760463.html