python多线程方式执行多个bat代码

yipeiwu_com6年前Python基础

python多线程方式执行多个bat的代码,感兴趣的朋友可以参考下。

import threading
from win32api import *

class MyThread(threading.Thread):
  def __init__(self, bat_path, **kwargs):
    threading.Thread.__init__(self, **kwargs)
    self.bat_path = bat_path
    
  def run(self):
    ShellExecute(0, None, self.bat_path, None, "c:", True)
  
for i in range(1,4):
  t = MyThread("c: est" + str(i) + ".bat")
  t.start()

以上就是本文的全部内容,希望对大家学习python程序设计有所帮助。

相关文章

python如何拆分含有多种分隔符的字符串

案例:        把某个字符串依据分隔符拆分,该字符包含不同的多种分隔符,如下    &nb...

DataFrame中去除指定列为空的行方法

一次,笔者在处理数据时想去除DataFrame中指定列的值为空的这一行,采用了如下做法,但是怎么都没有成功: # encoding: utf-8 import pandas as p...

详解Python_shutil模块

import shutil 高级的文件,文件夹,压缩包的处理模块,也主要用于文件的拷贝 shutil.copyfileobj(fsrc,fdst[,length]):  将文件的内容拷...

pytorch多进程加速及代码优化方法

目标:优化代码,利用多进程,进行近实时预处理、网络预测及后处理: 本人尝试了pytorch的multiprocessing,进行多进程同步处理以上任务。 from torch.mul...

Python3 执行Linux Bash命令的方法

和之前C++执行Linux Bash命令的方法 一样,Python依然支持system调用和popen()函数来执行linux bash命令。 方法一:system调用 #仅仅在一个...