Glass Hut - how to perform batch script file?

Preface:

Different business functions py points accumulated a lot of files in different directories, how to execute the script batch file? A script to be executed, efficiency is too low, borrowing python script batch file execution

Attach Code

import os
def func(path):
if os.path.isfile(path) and path.endswith('.py'):
os.system('python %s' % path)
elif os.path.isdir(path):
for name in os.listdir(path):
abs_path = os.path.join(path,name)
print(abs_path)
if abs_path.endswith('.py'):
os.system('python %s' % abs_path)

Py batch file path

func(r'D:\python\WorkProject\xxx')

Guess you like

Origin www.cnblogs.com/LLSHPower/p/12159863.html