摘要: __all__ = ["test"] from test import * 这里导入的是__all__列表中的内容。 __name__在自己的.py中是__main__ ,在其他模块导入是模块的名称。 阅读全文
posted @ 2017-10-11 21:02 我为Xin媛学Python 阅读(180) 评论(0) 推荐(0)
摘要: try: 可能出现异常的代码段 except 异常名: 出现异常的操作 python对于异常会有默认处理方式,当自己重写时会按照自己的处理方式执行 如果except Exception 可以捕获所有异常 except Exception as item: print(item) 可以捕获当前异常 e 阅读全文
posted @ 2017-10-11 20:04 我为Xin媛学Python 阅读(143) 评论(0) 推荐(0)
摘要: 1.单例模式 class Dog(object): __instance = None def __new__(cls): if cls.__instance == None: cls.__instance = object.__new__(cls) return cls.__instance el 阅读全文
posted @ 2017-10-11 19:38 我为Xin媛学Python 阅读(123) 评论(0) 推荐(0)