分类 Python 中的文章

Init_call

_init_()和_call_() _init_()相当于类的构造器 _call_(): ​ Python中的函数是一级对象,也就是说函数的引用可以作为输入传递到其他函……

阅读全文

With As

with语句,对于实现需要设置,事后做清理工作,with语句就能很好的处理: 在不用with语句: 1 2 3 4 5 file = open("/temp") try: data = file.read() finally: file.close() 使用with语句: 1 2 with open("/tmp/fs") as file: data = file.read()……

阅读全文