IndentationError:意外缩进(views.py,第40行)

时间:2013-12-29 03:17:33

标签: python python-2.7

我正在做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

错误:

else:
    x2 = 0

谢谢

此致 加米

1 个答案:

答案 0 :(得分:0)

缩进就是python中的一切。您遇到的问题是您正在使用的代码中的选项卡和空格的混合。重新排列所有内容并使用制表符或空格

相关问题