# -*- coding: UTF-8 -*- # 作者:幻灰龙 # 标题:Python 缩进规则 # 描述:Python 的缩进在一个源文件里要保持一致,例如都是4个空格或者都是2个空格 # 全局代码 for i in range(0, 10): print('global code: {}'.format(i)) if i == 5: print('global code: *') # 函数 def test(): for i in range(0, 10): print('function code: {}'.format(i)) if i == 5: print('function code: *') # 类 class Test(): def __init__(self) -> None: pass def test(self): for i in range(0, 10): print('member function code: {}'.format(i)) if i == 5: print('member function code: *') if __name__ == '__main__': i = 0 c = 5 max = 10 while i < max: d = max-i-i if abs(d) < 3: print(i, max-i) else: pass i += 1