我无法在 excel 中打印一行中的所有值

i cant print all values from i row in excell

我想在 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

我接受:

File "makelist.py", line 23 cell= wsact.cell(row = 9, column = c) ^ IndentationError: expected an indented block

我做错了什么?

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

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