![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python学习
文章平均质量分 80
Wink1993
我宁愿犯错,也不愿什么都不做。 -艾克
展开
-
闭包(closures)与python装饰器(Decorator)
1、闭包 (function closures)引用自有变量的函数,简单来说就是在自己函数内定义的变量,通过嵌套函数引用它间接意义上扩大它的作用域,使其影响到函数以外的区域。talk is cheap,show me the codedef print_msg(): msg = "I'm closure" # printer是嵌套函数 def printer...转载 2020-04-30 11:50:31 · 108 阅读 · 0 评论 -
python 线程初体验
import threadingimport timeclass myThread(threading.Thread): def __init__(self, threadID, name, counter): threading.Thread.__init__(self) self.threadID = threadID self...原创 2020-04-17 12:38:17 · 90 阅读 · 0 评论 -
python类执行顺序
class A: def __init__(self): self.n = 2 def add(self, m): print('self is {0} @A.add'.format(self)) self.n += mclass B(A): def __init__(self): self.n = ...原创 2020-04-17 11:50:00 · 783 阅读 · 0 评论 -
我的第一个python纪念一哈20180702
import random# guess = random.randint(1,101)# print("I'm thinking of a number! Try to guess the number I'm thinking of:")while 1: guess = random.randint(1, 100) print("I'm thinking of a num...原创 2018-07-02 23:33:11 · 170 阅读 · 0 评论 -
python学习,记录
1、zip函数 实例 :l = ['a', 'b', 'c', 'd', 'e','f']print zip(l[:-1],l[1:])print zip(*zip(l[:-1],l[1:]))输出结果:[('a', 'b'), ('b', 'c'), ('c', 'd'), ('d', 'e'), ('e', 'f')][('a', 'b', 'c', 'd', 'e'), ('b', 'c',...转载 2018-07-04 21:11:41 · 88 阅读 · 0 评论