IndentationError:意外缩进(视图)。py 40行)

时间:2021-12-01 23:17:46

i am doing python and i cant solve this error as it looks good. it displays error in else statement. I have following code:

我在做python,我不能解决这个错误,因为它看起来很好。它在else语句中显示错误。我有如下代码:

def getName():
    cur = django.db.connections['oprs'].cursor()
    #Execute a trivial SQL query which returns the name of 
    #all countries contained in 'world'
    cur.execute("SELECT * from available ")
    tmp = cur.fetchall()
    #Clean-up after ourselves
    for col in tmp:
        one_1 = col[2]
        one_2 = col[3]
  # one_3 = col[7]
  # two_1 = col[5]
  # two_2 = col[6]
  # two_3 = col[7]
    cur.close()
# x1 = 0, x2 = 0, x3 = 0
    if one_1 == 1:
        x1 = 1
    else:
        x1 = 0
    x5 = 5  
    if one_2 == 1:
        x2 = 1
    else:
        x2 = 0
# if one_2 == 1:
    # x2 = 1
# else:
    # x2 = 0
# if one_3 == 1:
    # x3 = 1

Error:

错误:

else:
    x2 = 0

Thank you

谢谢你!

Regards, Gami

问候,Gami

1 个解决方案

#1


0  

Indentation is everything in python. The problem that you face is the mixing of tabs and spaces in the code that you are using. Realign everything and use either tabs or spaces

缩进是python中的一切。您所面临的问题是您正在使用的代码中的制表符和空格的混合。重新调整一切,使用标签或空格。

#1


0  

Indentation is everything in python. The problem that you face is the mixing of tabs and spaces in the code that you are using. Realign everything and use either tabs or spaces

缩进是python中的一切。您所面临的问题是您正在使用的代码中的制表符和空格的混合。重新调整一切,使用标签或空格。