取出二维元组的第二维度
时间: 2023-05-25 08:04:45 浏览: 150
数据原理1
可以使用列表推导式或者循环来取出二维元组的第二维度。
1. 使用列表推导式
```python
t = [(1, 2), (3, 4), (5, 6)]
second_dimension = [x[1] for x in t]
print(second_dimension) # 输出 [2, 4, 6]
```
2. 使用循环
```python
t = [(1, 2), (3, 4), (5, 6)]
second_dimension = []
for x in t:
second_dimension.append(x[1])
print(second_dimension) # 输出 [2, 4, 6]
```
阅读全文