#-*-coding:utf-8-*-#1, Dictionary dict = {' name ': ' Zara ', ' age ': 7, ' class ': ' First '} #字典转为字符串, return: <type ' str ' > {' age ': 7, ' Nam E ': ' Zara ', ' class ': ' First '}print type (str (dict)), str (dict) #字典可以转为元组, return: (' age ', ' name ', ' class ') print tuple (dict) # Dictionaries can be converted to tuples, returning: (7, ' Zara ', ' first ') print tuple (Dict.values ()) #字典转为列表, return: [' age ', ' name ', ' class ']print list (dict) # Dictionary to list print dict.values#2, tuple tup= (1, 2, 3, 4, 5) #元组转为字符串, return: (1, 2, 3, 4, 5) print tup.__str__ () #元组转为列表, return: [1, 2, 3, 4, 5]pri NT List (TUP) #元组不可以转为字典 # #, List nums=[1, 3, 5, 7, 8, (+); #列表转为字符串, return: [1, 3, 5, 7, 8,, 20]print str (nums) #列表转为元组, return: (1, 3 , 5, 7, 8, () print tuple (nums) #列表不可以转为字典 # #, String # String to tuple, return: (1, 2, 3) Print tuple (eval ("())") #字符串转为列表, return: [1, 2, 3] Print List (eval ("())") #字符串转为字典, returns: <type ' Dict ' >print type (eval ("{' Name ': ' Ljq ', ' Age ': 24}")
"Go" python string/tuple/list/dictionary cross-turn