Preface:
Python pass is the null statement, which is intended to maintain the structural integrity of the program; pass doesn't do anything and is generally used as a placeholder statement.
The Python pass statement has the following syntax:
pass
Test Example:
an actual example
#!/usr/bin/python # -*- coding: UTF-8 -*- # Output every letter of Python for letter in 'Python': if letter == 'h': pass print 'This is the pass block.' print 'Current letter :', letter print "Good bye!"
Results of the above example execution:
Current letter : P
Current letter : y
Current letter : t
Here's the pass block.
Current letter : h
Current letter : o
Current letter : n
Good bye!
The Python version is the main one:
Scene:The pass statement can be used as a placeholder in a loop or judgment logic statement to maintain structural integrity and to save additional code for later use.
passstatement while Requirements for establishment: if i%7==0: pass else print('Current traversal value: %s' % (value))
The code is as follows:
#!/usr/bin/python3 # -*- coding: utf-8 -*- import json day=0; jsonString='[{"day":"7","prize":"Prize 2 for 1, oversized mouse pad/customized fridge sticker"},{"day":"14","prize":"3 choices of prizes, oversized mouse pad/customized fridge sticker/year of the tiger notebook"},{"day":"21","prize":"3 out of 5 prizes, oversized mouse pads/customized fridge stickers/Year of the Tiger notebooks/shoulder bags/WuKong Bear figures"}]'; jsonObject = (jsonString) # Loop nested statements while day<=21: day+=1 if day%7==0: index=int(day/7) item=jsonObject[index-1] print('Bonus for %successive %sday of more writing: %s\r\n' % (item['day'],item['prize'])) else: pass
The effect is as follows:
to this article on the Python pass placeholder statement of the article is introduced to this, more related Python pass statement content please search for my previous articles or continue to browse the following related articles I hope you will support me more in the future!