通过批处理文件运行时未执行py文件

时间:2019-02-02 11:19:35

标签: python

我正在尝试在按钮按下事件后按顺序运行批处理文件。

我有solution.py并尝试通过批处理文件solution.bat运行 START / WAIT Python.exe“ C:/..../ solution.py

此文件得到完全&稍后执行

Test.py具有以下代码,请尝试从批处理文件test.bat运行 START / WAIT Python.exe“ C:/..../ Test.py

import datetime
import time
Date = datetime.datetime.now().strftime("Date: %d/%m/%y")
time = datetime.datetime.now().strftime("Time: %H:%M:%S")
text_file = open("C:XXX.txt", "w")
text1_file = open("C:YYY.txt", "w")
import os
for file in os.listdir("C:\ZZZ"):
  if file.endswith(".txt"):
   print(file)
   cloud_file = open(file, "r")
   if '#####' in open(file).read():
       print ####
   else:
       Print $$$$$

     text_file = open("C:XXX.txt", "r")
   count = 0
   for line in text_file.readlines():
       for word in line.split():
       if word == 'Pass':
        count= count + 1
    print('Pass',count,'TC')
    text_file = open("C:XXX.txt", "r")
    count1 = 0
    for line in text_file.readlines():

for word in line.split():
    if word == 'Fail':
        count1= count1 + 1
       print('Fail',count1,'TC')

text1_file = open("C:YYY.txt", "w")

 count = 0
 for line in text1_file.readlines():
     for word in line.split():
         if word == 'Pass':
        count= count + 1
        print('Pass',count,'TC')

   text1_file = open("C:YYY.txt", "w")
   count1 = 0
   for line in text1_file.readlines():


   for word in line.split():
    if word == 'Fail':
       count1= count1 + 1
      Print('Fail',count1,'TC')

按顺序,solution.bat将打开并完全执行solution.py文件。然后打开test.bat并执行代码test.py,直到仅创建xxx.txt和YYY.txt文件,而其余代码不执行。

任何帮助。

1 个答案:

答案 0 :(得分:0)

我喜欢这个答案。 os.listdir(“ C:\ ZZZ”)中的路径重定位到主文件夹并得到输出。 谢谢大家

相关问题