当前位置:首页 > 技术杂坛 > 正文内容

python函数开启多线程

zhangchap3年前 (2021-06-05)技术杂坛241
from threading import Thread
以下是代码举例:

def main(num):
    pass

if __name__ == '__main__':
    threads = []
        for i in range(5):
            t = Thread(target=main,args=(100,))
            t.daemon = True
            t.start()
            threads.append(t)

        for t in threads:
            t.join()


标签: python笔记
分享给朋友:

相关文章

python使用mongodb数据库

from pymongo import MongoClient,collection class KSpdier(Thread):   ...

python 函数 开启多线程示例

from threading import Thread def readfile(queue:Queue):    &nbs...

python jieba分词

import jieba from jieba.analyse import tfidf words = jieba.lcut('...

python url.parse模块编码解码

from urllib.parse import quote,unquote,urlencode # 对汉字进行编码使用 quote ...

pip install 安装出现:Requirement already satisfied 的解决办法

刚开始装上python安装轮子挺顺利的,后来再使用pip install 安装开始报错,网上有解决方案说用国内的源就没问题,但是我的源早就改成国内的了,用了另外一种解决方案,搞定加上--target参...

python判断当前系统为win还是Linux

使用sys模块进行判断,以便启用在win平台下不支持的代码:import sys p = sys.platform if p != &#...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。