Python pass语句

Python pass语句:空语句,主要用于保持程序结构的完整性 或者 函数想要添加某种功能,但是还没有想好具体应该怎么写。

在 for 循环中使用 pass:

lst = [7,8,9,4]
for i in range(len(lst)):
    if lst[i] == 8:
        pass #对函数运行无影响
    print(lst[i],end = "  ")
# 7  8  9  4 

在函数中使用 pass:

def run():
    pass

在类中使用 pass:

class Person(object):
    pass

2020-02-06

原文地址:https://www.cnblogs.com/hany-postq473111315/p/12268565.html