數據類型間轉換

經常使用數據類型間轉換字符串

str--->list      split('')it

list-->str    str1 = 'x'.join(l1)class

 

str-->tuple   t1 = tuple(str1)數據類型

list-->tuple   t1 = tuple(l1)數據

 

字符串---->字典dict

a='{"name":"yct","age":10}' di

print(a)     # {"name":"yct","age":10} <class 'str'>字典

print(eval(a))     #{'name': 'yct', 'age': 10} <class 'dict'>
相關文章
相關標籤/搜索