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

yipeiwu_com5年前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 函数内部修改外部变量的方法

如果内部修改外部变量需要nonlocal,global def f1(): print("in f1..") num=111 def f2(): nonlocal num...

Python中方法链的使用方法

方法链(method chaining)是面向对象的编程语言中的一种常见语法,可以让开发者在只引用对象一次的情况下,对同一个对象进行多次方法调用。举个例子: 假设我们有一个Foo类,其中...

Python调用百度根据经纬度查询地址的示例代码

如下所示: def locatebyLatLng(lat, lng, pois=0): ''' 根据经纬度查询地址 ''' items = {'location': str(...

python根据京东商品url获取产品价格

京东商品详细的请求处理,是先显示html,然后再ajax请求处理显示价格。 1.可以运行js,并解析之后得到的html 2.模拟js请求,得到价格 # -*- coding: utf...

python paramiko实现ssh远程访问的方法

安装paramiko后,看下面例子: 复制代码 代码如下:import paramiko #设置ssh连接的远程主机地址和端口t=paramiko.Transport((ip,port)...