我无法打印excel中第i行的所有值

问题描述 投票:0回答:1

我想从 Excel 中的一行中获取所有值...

对于我使用的一个特定单元:

  c=5
cell= wsact.cell(row = 9, column = c) 
print(cell.value)

我取9行5列单元格的值。 如果我想获取前 10 列的所有值,我使用:

    c=1
while c<=10:
cell= wsact.cell(row = 9, column = c) 
print(cell.value)
c=c+1

我认为:

文件“makelist.py”,第 23 行 单元格= wsact.cell(行= 9,列= c) ^ IndentationError:需要一个缩进块

我做错了什么?

python loops while-loop openpyxl cell
1个回答
0
投票

您需要缩进 while 语句下方的所有内容:

c=1
while c<=10:
    cell= wsact.cell(row = 9, column = c) 
    print(cell.value)
    c=c+1
© www.soinside.com 2019 - 2024. All rights reserved.