上一页 1 ··· 37 38 39 40 41
摘要: 1. 进程以及状态 1.1 进程 程序:例如xxx.py这是程序,是一个静态的 进程:一个程序运行起来后,代码+用到的资源 称之为进程,它是操作系统分配资源的基本单元。 不仅可以通过线程完成多任务,进程也是可以的 1.2 进程的状态 工作中,任务数往往大于cpu的核数,即一定有一些任务正在执行,而另 阅读全文
posted @ 2019-12-29 02:42 1769987233 阅读(174) 评论(0) 推荐(0)
摘要: 1. 线程 线程的创建 使用threading模块能完成多任务的程序开发,为了让每个线程的封装性更完美,所以使用threading模块时,往往会定义一个新的子类class,只要继承threading.Thread就可以了,然后重写run方法 示例如下: #第一种 import threading i 阅读全文
posted @ 2019-12-29 01:46 1769987233 阅读(209) 评论(0) 推荐(0)
摘要: 1、先明白这段代码 def foo(): print('foo') foo # 表示是函数 foo() # 表示执行foo函数 def foo(): print('foo') foo = lambda x: x + 1 foo() # 执行lambda表达式,而不再是原来的foo函数,因为foo这个 阅读全文
posted @ 2019-12-28 23:58 1769987233 阅读(135) 评论(0) 推荐(0)
摘要: 1. 函数引用 def test1(): print("测试函数") test1() # 测试函数 ret = test1 print(id(ret)) # 1929668379992 print(id(test1)) # 1929668379992 ret() # 测试函数 2. 什么是闭包 # 阅读全文
posted @ 2019-12-28 23:34 1769987233 阅读(107) 评论(0) 推荐(0)
摘要: import threading, time class Test(): def test1(self): print("--") time.sleep(3) print(" ") def test2(self): print("==") time.sleep(3) print(" ") def r 阅读全文
posted @ 2019-12-28 03:34 1769987233 阅读(160) 评论(0) 推荐(0)
上一页 1 ··· 37 38 39 40 41