常用数据类型间转换
str--->list split(‘‘)
list-->str str1 = ‘x‘.join(l1)
str-->tuple t1 = tuple(str1)
list-->tuple t1 = tuple(l1)
字符串---->字典
a=‘{"name":"yct","age":10}‘
print(a) # {"name":"yct","age":10} <class ‘str‘>
print(eval(a)) #{‘name‘: ‘yct‘, ‘age‘: 10} <class ‘dict‘>
原文地址:https://www.cnblogs.com/shangerzhong/p/9006342.html
时间: 2024-11-08 10:45:34