PYTHON使用小结

线程使用

python 复制代码
import threading

thread01 = None

def ThreadFunc(param)
    xxxxx


def Test()
    global thread01 
    thread01 = threading.Thread(target=ThreadFunc)
    thread01.daemon = True  #设置为TRUE,主线程结束后,此线程也会退出, 默认False
    thread01.start()
    
    

也可以在创建线程时给参数

thread01 = threading.Thread(target=ThreadFunc,name="t1",daemon=True)

等待线程中止

thread01.join()

相关推荐
叫我:松哥7 分钟前
基于Python的共享单车租赁数据分析与预测系统,技术栈flask+boostrap+随机森林+XGBoost
人工智能·python·深度学习·算法·随机森林·数据分析·flask
Li#16 分钟前
web端电商项目自动下单发货评价晒图需要用到的能力
python·自动化
雨辰AI36 分钟前
从零搭建大模型本地运行环境|Python+CUDA 基础配置避坑大全
大数据·开发语言·人工智能·python·ai·ai编程·ai写作
DogDaoDao1 小时前
【第 05 篇】Python的字典与集合
开发语言·python·集合·字典
涛声依旧-底层原理研究所1 小时前
混合检索 + 重排:让 AI Agent 拥有「既全又准」的认知骨架
人工智能·python
努力写A题的小菜鸡1 小时前
01-PyTorch加载数据初认识(dataset运用)
人工智能·pytorch·python
abcy0712131 小时前
python fastapi celery hdfs 异步上传
python·hdfs·fastapi
Dxy12393102161 小时前
Python多线程如何操作全局变量:从踩坑到最佳实践
python
SilentSamsara1 小时前
RAG 系统入门:LangChain/LlamaIndex + Chroma 向量数据库的检索增强实战
数据库·人工智能·python·青少年编程·langchain
码云骑士1 小时前
06-Python装饰器从入门到源码(上)-闭包与自由变量
开发语言·python