1,换值
a, b = b, a
2,真值测试
if a and b:
真:任意非空字符串,任意非0数字,任意非空容器,其他任意非False
假:空的字符串,数字0,空的容器 [] () {} set(),None
3,分母为0的异常处理
def divide(a,b) try: return a/b except ZeroDivisionError: return None
原文:https://www.cnblogs.com/guxh/p/10273576.html