Today I learned a little Python and figure out the difference of pass and continue
test code
mylist = ["zope","python","perl","linux"]
for technic in mylist:
if technic == "perl":
pass#this is pass
else:
print technic
print "Hello World"
- - - - - - - - - - - - - - - - -
output :
zope
Hello World
python
Hello World
Hello World
linux
Hello World
- - - - - - - - - - - - - - - - -
mylist = ["zope","python","perl","linux"]
for technic in mylist:
if technic == "perl":
continue
else:
print technic
print "Hello World"
- - - - - - - - - - -
zope
Hello World
python
Hello World
linux
Hello World
pass statement has print one more "hello world"
continue语句会忽略后面的语句,强制进入下一次循环。
pass不做任何事情。