Lệnh pass trong Python

Lệnh pass trong Python

Lệnh pass trong Python

Learn more »


Lệnh pass, giống như tên của nó, được sử dụng khi một lệnh là cần thiết theo cú pháp nhưng bạn không muốn bất cứ lệnh hoặc khối code nào được thực thi. Lệnh pass là một hoạt động null và không có gì xảy ra khi nó thực thi. Dưới đây là cú pháp của lệnh pass:

pass

Dưới đây là ví dụ minh họa lệnh pass trong Python:

for letter in 'Python':     if letter == 'h':       pass       print 'Day la khoi pass'    print 'Chu cai hien tai :', letter  print "Good bye!" 

Khi code trên được thực thi sẽ cho kết quả:

Chu cai hien tai : P Chu cai hien tai : y Chu cai hien tai : t Day la khoi pass Chu cai hien tai : h Chu cai hien tai : o Chu cai hien tai : n Good bye!


Lượt xem : 209

Integrations
Users

Share Profile

Anyone at KeenThemes can view
Anyone with link can edit

Give Award

Anyone at KeenThemes can view
Anyone with link can edit

Report User

Let us know why you’re reporing this person
Don't worry, your report is completely anonymous; the person you're
reporting will not be informed that you've submitted it