同步操作将从 pish7/stdpython 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# 值为 False 的表达式包括:# False None 0 "" () [] {}# 其他值都视为 True# True 和 False 不过是 0 和 1 的别名print(bool(None)) # Falseprint(True == 1) # Trueprint(True == 2) # Falseprint(False == 0) # Trueprint(False + True + 2) # 3# 条件表达式,类似于三目运算符a = Trueb = "a" if a else "b"print(b) # aif True:"""""" # 用一个字符串来起到空语句的作用if True:pass # 空语句x = [1, 2, 3]y = [1, 2, 3]z = x# 相等if x == y:print("x=y") #else:print("x!=y")# x和y是同一个对象if x is y:print("x is y")else:print("x is not y") ## x和y不是同一个对象if x is not z:print("x is not z")else:print("x is z") ## 1是容器(如序列)x的成员if 1 in x:print("1 in x") #else:print("1 not in x")# 2不是容器(如序列)x的成员if 2 not in x:print("2 not in x")else:print("2 in x") #x = "abc"y = "def"z = x or yprint(z) # abcx = "abc"y = "def"z = x and yprint(z) # defx = Noney = "def"z = x and yprint(z) # Noney = "def"z = not yprint(z) # False# 链式比较a = 3if 0 <= a <= 9:print("ok")# 断言age = 10assert 0 < age# 断言测试不通过时将抛出异常try:age = -1assert 0 < age, "年龄必须为整数"except Exception as e:print(e) # 年龄必须为整数x = 0y = 1assert x < y # 通过assert x or y # 通过# assert x and y #异常
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。