Python3_测验 - 条件判断与循环
#!/usr/bin/python # -*- coding: utf-8 -*- #Author: zhaosj if None: print("Hello")
#执行结果:
None 为 False,所以没有任何输出
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/usr/bin/python # -*- coding: utf-8 -*- #Author: zhaosj for i in [1, 0]: print(i+1)
Python 中,for 和 while 可以有 else 语句?
for 和 while 都可以有 else 语句
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/usr/bin/python # -*- coding: utf-8 -*- #Author: zhaosj while 4 == 4: print('4')
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
迭代输出序列时(如:列表)使用 for 比 while 更好?
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#!/usr/bin/python # -*- coding: utf-8 -*- #Author: zhaosj for char in 'PYTHON STRING': if char == ' ': break print(char, end='') if char == 'O': continue
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++