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

python函数开启多线程

zhangchap3年前 (2021-06-05)技术杂坛242
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 随机生成时间戳写入txt文件/运行sql语句

import time from random import randint with open('time.txt', ...

python jieba分词

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

python url.parse模块编码解码

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

python fake_useragent 模块用法

我们每次发送requests请求时通过random从中随机获取一个随机UserAgent,两行代码即可完成UserAgent的不停更换 from fake_useragent i...

python列表排序(以字符串长度)

M = ['a', 'sss', 'bb'] 第一种: m = M.sort(key&n...

发表评论

访客

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