摘要: contextlib模块中包含的工具用于处理上下文管理器和with语句 上下文管理器由with语句启用,执行流进入with中的代码块会运行__enter__()方法,它返回在这个上下文中使用的一个对象,执行流离开with块时,则执行上下文管理的__exit__(exc_type,exc_val,ex 阅读全文
posted @ 2019-03-31 21:58 superniao 阅读(115) 评论(0) 推荐(0) 编辑
摘要: for i in range(10): if i == 5: break print(i) else: print('*'*10) #程序触发break else语句不会执行 for i in range(10): if i == 5: continue print(i) else: print('*'*10) ... 阅读全文
posted @ 2019-03-31 21:38 superniao 阅读(101) 评论(0) 推荐(0) 编辑
摘要: python的第一类对象的简易用法: 字符串的方法: 字典的方法: 阅读全文
posted @ 2019-03-31 18:09 superniao 阅读(126) 评论(0) 推荐(0) 编辑