摘要:
把子线程设置为守护线程,主线程活干完了,不管子线程是否在运行中,都结束程序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 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 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、单继承class Lw: #定义类 money = 10000 def eat(self): #吃饭功能 print("eat") def __fly(self): print(" 阅读全文
posted @ 2021-11-18 14:25
王王的王
阅读(150)
评论(0)
推荐(0)
摘要:
#类里面的其他方法#公有的变量,随着类一起被定义1、类方法意思:不需要实例化也可以调用的方法特点:通过类名直接调用,但是不能调用实例方法,可以调用类变量以及其他类方法定义:在方法前加上@classmethodimport timeclass Person: #定义这个类,# 类变量:公共的 随着类一 阅读全文
posted @ 2021-11-18 14:14
王王的王
阅读(141)
评论(0)
推荐(0)

浙公网安备 33010602011771号