python tuple和list转换
时间: 2023-04-30 14:01:55 浏览: 202
Python代码-set-list-tuple三者类型间转换.py
可以使用内置函数tuple()和list()进行tuple和list之间的转换,例如:
```
# tuple to list
t = (1, 2, 3)
l = list(t)
print(l) # [1, 2, 3]
# list to tuple
l = [1, 2, 3]
t = tuple(l)
print(t) # (1, 2, 3)
```
阅读全文