python使用openpyxl读取数据_python - [使用openpyxl在Python中逐行读取数据 - SO中文参考 - www.soinside.com...

我正在尝试以[[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 ...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值