1 2 3 4 5 ··· 7 下一页
摘要: import multiprocessing,time,osqq_numbers = ["511402865","260303838","1099276647","1490768397","729226162", "1164019076","569380213","923296994","33054 阅读全文
posted @ 2021-11-19 10:26 王王的王 阅读(31) 评论(0) 推荐(0)
摘要: 1、概念:资源的集合,如图片,文字等 进程大,线程小 2、特点: 任务分类: (1)io密集型:读写数据,对cpu没有很大工作量,只负责调度,适合多线程 (2)cpu密集型:需要计算的任务,如排序等,适用于多进程 import multiprocessingimport threadingimpor 阅读全文
posted @ 2021-11-19 10:26 王王的王 阅读(58) 评论(0) 推荐(0)
摘要: #需要处理很多数据 #1000->30#最大多少数据,告诉线程池我有多少任务去处理from concurrent.futures import ThreadPoolExecutorimport requestsimport hashlibimport threadingdef down_pic(ur 阅读全文
posted @ 2021-11-19 10:21 王王的王 阅读(56) 评论(0) 推荐(0)
摘要: import threading,timeclass MyThread(threading.Thread): def __init__(self,name): super().__init__() self.name = name def run(self): time.sleep(1) # pri 阅读全文
posted @ 2021-11-18 14:45 王王的王 阅读(41) 评论(0) 推荐(0)
摘要: 把子线程设置为守护线程,主线程活干完了,不管子线程是否在运行中,都结束程序import threadingimport timedef make_money(name): print(f"{name}修建陵墓") time.sleep(20) print(f"f{name},活干完了")for i 阅读全文
posted @ 2021-11-18 14:45 王王的王 阅读(169) 评论(0) 推荐(0)
摘要: import requestsimport threadingimport hashlibimport timedef down_pic(url): print("开始下载",url) r = requests.get(url) file_name = hashlib.md5(url.encode( 阅读全文
posted @ 2021-11-18 14:42 王王的王 阅读(342) 评论(0) 推荐(0)
摘要: import threading #多线程的情况容易出错,就需要加锁了number = 0lock = threading.Lock() #锁 实例化def add(): global number for i in range(1000): with lock: #自动判断 number += i 阅读全文
posted @ 2021-11-18 14:40 王王的王 阅读(124) 评论(0) 推荐(0)
摘要: 主线程:py文件是一个进程,这个进程里面有一个自带的线程,称之为主线程import threading #线程都是同时运行的,程序最小的执行单位import timedef saodi(thread): #定义函数,找了个人,让这个人去干什么 print("%s扫地" % thread) time. 阅读全文
posted @ 2021-11-18 14:39 王王的王 阅读(234) 评论(0) 推荐(0)
摘要: import jsonpath #是一种语法 解析jsond = {'status': 0, 'msg': 'ok', 'result': {'channel': '头条', 'num': 10, 'list': [ {'title': '梅森三双陶汉林20+11 郭士强复出广州大胜山东', 'ti 阅读全文
posted @ 2021-11-18 14:28 王王的王 阅读(307) 评论(0) 推荐(0)
摘要: class A(object): #新式类 def eat(self): #有个eat方法 print("a eat") passclass B(A): #B继承了A # def eat(self): # print("b eat") passclass C(A): #C也是继承了A def eat 阅读全文
posted @ 2021-11-18 14:26 王王的王 阅读(45) 评论(0) 推荐(0)
1 2 3 4 5 ··· 7 下一页