python数据类型之间的转换
77 ** 二.数据类型的转换 **
78 1.
79 int 转 str
80 a = 123
81 print(str(a))
82 print(type(str(a)))
83 2.
84 str 转 int
85 a = "123"
86 print(int(a))
87 print(type(int(a)))
88 3. str 转 list
89 a = "123"
90 print(list(a))
91 print(type(list(a)))
92 4. str 转 tuple
93 a = "123"
94 print(tuple(a))
95 print(type(tuple(a)))
96 5. list 转 tuple
97 a = [1, 2, 3]
98 print(tuple(a))
99 print(type(tuple(a)))
100 6. tuple 转 list
101 a = (1, 2, 3)
102 print(list(a))
103 print(type(list(a)))
104 7. list 转 set
105 a = [1, 2, 3]
106 print(set(a))
107 print(type(set(a)))
108 8. tuple 转 set
109 a = (1, 2, 3)
110 print(set(a))
111 print(type(set(a)))
112 9. set 转 list
113 a = {1, 2, 3}
114 print(list(a))
115 print(type(list(a)))
116 10. set 转 tuple
117 a = {1, 2, 3}
118 print(tuple(a))
119 print(type(tuple(a)))