我正在尝试以[[a,b],[c,d],...]格式获取python中的列表]
作为示例,下面是excel中的两列:R1 R2
1 2
6 2
0 9
3 2
4 1
5 6
我应该获得一个列表= [[1,2],[6,2],[0、9],[3,2],[4,1],[5,6]]
我的代码如下所示:R = []
# iterate over column
for col in range(min_column+3, max_column+1): #location of the data
# u_need reads in the resource needed for each activity
u_need = []
# iterate over row
for row in range(2, max_row+1): #row 1 is not included
# loop until blank space is encountered
if (sheet.cell(row,col).value is not None):
u_need.append(sheet.cell(row,col).value);
R.append(u_need)
print(f'R = {R}')
但是结果给了我类似的东西:R = [[1, 6, 0, 3, 4, 5], [2, 2, 9, 2, 1, 6]]
我有办法改变这一点吗?任何帮助,将不胜感激!谢谢!
[我正在尝试以[[a,b],[c,d],...]格式获取python中的列表,例如,对于以下两个excel列:R1 R2 1 2 6 2 0 9 3 2 4 1 5 ...