在循环中创建变量的语法错误

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

我正在尝试在这些循环中创建变量,但是python给了我一个语法错误。 tmeempty都给我这个问题。我试图让python读取Excel工作表并将值放在列表中。我正在尝试创建的变量应该可以帮助我在python中找到空白区域,并从另一个创建的列表中删除该值,以便获取的值与正确的输入相对应,并且在excel中没有任何值的输入也将被删除。从该列表中。如果有解决的办法,它也会给出索引错误,对此我将不胜感激,但我可以弄清楚这些变量是否正常工作。

span = list()
print(span)
price = list() #creates a list with all the values before giving index error
for q in range(1,chart.nrows):
    for i in range (1,chart.ncol):
        L = (chart.cell_value(q,i))
        if L != '': #all values that exist will be appended to the list
            price.append(L)
        else: #find x and y parts of space, have that popped from span list
            moth = chart.cell_value(q,0)
            m = str(moth)
            y = year = str(chart.cell_value(0,i)
            tme = m + ' ' + y
            empty = span.index(tme)
            span.pop(empty)
python python-3.x variables syntax index-error
1个回答
0
投票

[从语法的角度来看,您在]中缺少右括号

y = year = str(chart.cell_value(0,i))
© www.soinside.com 2019 - 2024. All rights reserved.