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实现从url中提取域名的几种方法

从url中找到域名,首先想到的是用正则,然后寻找相应的类库。用正则解析有很多不完备的地方,url中有域名,域名后缀一直在不断增加等。通过google查到几种方法,一种是用Python中自...

Python错误提示:[Errno 24] Too many open files的分析与解决

背景 最近在工作中发现了一个错误,在执行多线程扫描脚本的时候频繁出现下面这个错误 HTTPConnectionPool(host=‘t.tips', port=80): Max re...

浅析Python 3 字符串中的 STR 和 Bytes 有什么区别

浅析Python 3 字符串中的 STR 和 Bytes 有什么区别

Python2的字符串有两种:str和Unicode,Python3的字符串也有两种:str和Bytes。Python2的str相当于Python3的Bytes,而Unicode相当于P...

wxPython定时器wx.Timer简单应用实例

wxPython定时器wx.Timer简单应用实例

本文实例讲述了wxPython定时器wx.Timer简单应用。分享给大家供大家参考。具体如下: # -*- coding: utf-8 -*- #################...

Python清空文件并替换内容的实例

有个文本文件,需要替换里面的一个词,用python来完成,我是这样写的: def modify_text(): with open('test.txt', "r+") as f:...