python的tab与空格

python的对齐错误:

IndentationError:excepted an indented block

缺少一个缩进,如果这一列是tab缩进的就tab’一个,空格就空4个。

python空格标准

同一列的空格个数及空格方式应保持一致。

空格个数一致

def abc():
    a = 3
    b = 4
    c = a+b
    return c

空格方式一致

def qwe()
四个空格,a = 3
四个空格,b = 4
四个空格,if a == b:
tab,tab,   c = a*2
四个空格,else:
tab,tab,   return a+b
...


猜你喜欢

转载自blog.csdn.net/san_junipero/article/details/79956716