python batch run py files

import os

path="E:\\python"  #Batch py file path

for root,dirs,files in os.walk(path): #Enter the folder directory
 for f in files: #Files under the folder
  if os.path.splitext(f)[1]=='.py': #Run only py files
   os.chdir(root)
   os.system('python {}'.format(f))  #Terminal run python main.py

Recommended Posts

python batch run py files
Python renames files
Python reads files by line
3 ways to encrypt Python files
Python realizes batch naming photos
Talking about php calling python files
How does Python generate xml files
Python reads and writes json files
Install Python3 and Py under CentOS7