12 2019 档案

摘要:生成斐波那契数列 def fibo(num): numlist = [0,1] for i in range(num-2): numlist.append(numlist[-2] + numlist[-1]) print(numlist) return numlist 阅读全文
posted @ 2019-12-02 23:48 王军的个人博客 阅读(111) 评论(0) 推荐(0)
摘要:上下文管理器:实现__enter__方法和__exit__方法的类就是一个上下文管理器: 示例代码: from contextlib import ContextDecorator class Mycontext(ContextDecorator): def __enter__(self): pri 阅读全文
posted @ 2019-12-01 22:37 王军的个人博客 阅读(109) 评论(0) 推荐(0)