共 62 篇文章
显示摘要每页显示  条
进程池和线程池、协程。ThreadPool(2)#创建线程池 #p=Process()创建进程池 #p.apply(func,args.kwargs) 执行进程 #p.close() p.jion() requests = threadpool.makeRequests(sayhello,seed)#创建任务 makeRequests(func,args,kwargs) for request in requests: task_pool.putRequest(request)#把任务put到线程池中 task_pool.wait()#执行等待线...
python 进度条for i in range(100):print(">",end="",flush = True) #flush默认为False ,设置成True 实时打印缓存信息for i in range(10):print("\r"+"<" * i,end = "") #\r默认将指针返回到最开始后输出(在原位置再次输出)
#match 从要被匹配的字符串开头开始匹配, 如果没有匹配到返回Nonea = re.match("c","abc")#search 在被匹配的字符串中寻找匹配,如果使用^就等价于matcha = re.search("c","abc").group()a = re.search("^c","abc")#返回一个正则表达式对象pattern = re.compile("A")....
python---类装饰器和函数装饰器函数装饰器如下: 类装饰器写法:__init__:初始化类__call__:给实例对象赋予函数执行的功能。
python global、locals()、nonlocalglobal 定义全局变量,必须先声明,在使用例如:global a #声明全局变量 a = a+1locals() 获取本函数作用域中的局部变量(函数即变量)nonlocal 必须在整个嵌套函数作用域内定义局部变量,获取上层函数的变量例如:1.def test():a = 1def test1():nonlocal a #必须先声明a = a+1print (a)return test1t = ...
python 静态属性、静态方法、静态类。#静态属性 @property #定制静态属性方法,跟实例绑定,让用户感知不到后端的运行逻辑 def room(this): return this.w*this.l.#类方法 @classmethod #类方法:跟类绑定,和实例没有任何关系,只是类级别的操作时用,实例也可以调用 def tell_info(cls): print(cls) print(cls.x)#静态方法 @staticmethod #静...
帮助 | 留言交流 | 联系我们 | 服务条款 | 下载网文摘手 | 下载手机客户端
北京六智信息技术股份有限公司 Copyright© 2005-2024 360doc.com , All Rights Reserved
京ICP证090625号 京ICP备05038915号 京网文[2016]6433-853号 京公网安备11010502030377号
返回
顶部