python - 运行目录中的所有 Python 文件

标签 python bash matplotlib

运行目录中所有 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/

相关文章:

python - 用 mode() 填充 NAN 数据不起作用-Pandas

mysql - 如何将日志文件记录到mysql数据库

node.js - child_process 给出 'Command failed' 执行 grep

python - 在 matplotlib 中使用 ax.annotate 返回箭头和文本

python - 在 Matplotlib 上显示 x 轴 - Python

python - 为什么 '[0-9]*' 与我的 Python 正则表达式中的 'abc' 不匹配,因为字符串中有零个或多个数字?

python - 无法在 python 中实现 __repr__() 方法

python - 无法使用 numpy load() 加载数组

bash - gnu watch : justify on the lower left of the terminal

python - 从数组编写动画散点图