运行目录中所有 Python 文件的最佳方式是什么?
python *.py
只执行一个文件。在 shell 脚本(或 make 文件)中为每个文件写一行似乎很麻烦。我需要这个 b/c 我有一系列小的 matplotlib 脚本,每个脚本创建一个 png 文件并想一次创建所有图像。
PS:我使用的是 bash shell。
最佳答案
bash 有循环:
for f in *.py; do python "$f"; done
关于python - 运行目录中的所有 Python 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5015316/