Python学习笔记之关键字

2019-9-19 张宇童 Python

# pass break continue 关键字
# pass 用来占位
# example1
# if True: 
    # 如果这里什么都没有写 将会报错
    # File "/Users/root/Desktop/# pass break continue example.py", line 5
# example2
if True:
    pass # 如果加上pass 将不会报错
    # print(123)

# example3
a = 0
while a < 10:
    pass
    a+=1

# example4
n = 0
while n < 100:
    n+=1
    # print(n)
    if n >= 5: 
        break 

# example5
n = 0;
while n < 10:
    n+=1
    if n % 2 == 1:
        continue
    
    print(n)

标签: python 学习笔记

发表评论:

Powered by emlog