python的pass語句
python中的pass語句 (pass statement in python)
"pass" is a type of null operation or null statement, when it executes nothing happens. It is used when you want do not want to write any code/statement to execute but syntactically a statement is required.
“ pass”是空操作或空語句的一種,執行時不執行任何操作。 當您不想編寫任何代碼/語句來執行但在語法上需要一條語句時,可以使用它。
Let’s consider the given example...
讓我們考慮給定的例子...
Here, we are using "pass" statement in the function hello() definition - there is no statement in the function and if we do not use "pass", there will be an error.
在這里,我們在函數hello()定義中使用“ pass”語句-函數中沒有語句,如果我們不使用“ pass” ,則會出現錯誤。
def hello():
pass
hello()
Example 2:
范例2:
for i in range(1,11):
if(i==6):
continue
else:
pass
print(i)
Output
輸出量
1
2
3
4
5
7
8
9
10
翻譯自: https://www.includehelp.com/python/pass-with-example.aspx
python的pass語句