如何批量执行一系列Python脚本? [英] How to execute a series of Python scripts in batch?

查看:110
本文介绍了如何批量执行一系列Python脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常发现我需要顺序运行一系列python脚本.这些脚本的顺序和数量可能会有所不同,但是有没有一种首选的方式可以批量自动化一系列Python脚本,而不是逐个依次执行每个脚本?我的程序需要多个复杂的文件路径以及其他参数组合.

I frequently find that I need to run a series of python scripts sequentially. The order and number of these scripts may vary, but instead of executing each script individually and sequentially, is there a preferred way of batch automating a series of Python scripts? My programs require multiple and complex file path and other argument combinations.

推荐答案

将它们重构为模块,然后创建一个新脚本,该脚本import隔离每个模块的相关功能并运行这些功能.

Refactor them into modules, then make a new script that imports the relevant functions from each module and runs those.

最简单的方法是为每个模块编写一个main函数,然后依次运行所有main函数.

The easiest way to do this is to write a main function per module and run all the main function serially.

这篇关于如何批量执行一系列Python脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆