(1)list 转为 tuple:
-
temp_list = [
1,
2,
3,
4,
5]
-
print(temp_list)
-
print(
type(temp_list))
-
a =
tuple(temp_list)
#将temp_list进行强制转换
-
print(a)
-
print(
type(a))
#查看是否转换成功
(2)tuple 转为 list:
-
temp_tuple = (
1,
2,
3)
-
print(temp_tuple)
-
print(
type(temp_tuple))
-
b =
list(temp_tuple)
#将temp_tuple进行强制转换
-
print(b)
-
print(
type(b))
#查看是否转换成功
结果如下: