How to use the pass statement?

2019-01-01 04:39发布

I am in the process of learning Python and I have reached the section about the pass statement. The guide I'm using defines it as being a Null statement that is commonly used as a placeholder.

I still don't fully understand what that means though. Can someone show me a simple/basic situation where the pass statement would be used and why it is needed?

标签: python
13条回答
梦该遗忘
2楼-- · 2019-01-01 05:39

as the book said, I only ever use it as a temporary placeholder, ie,

# code that does something to to a variable, var
if var == 2000:
    pass
else:
    var += 1

and then later fill in the scenario where var == 2000

查看更多
登录 后发表回答