从Mac终端多次运行python文件

时间:2018-12-05 13:09:49

标签: python-3.x macos terminal

我记得在终端中使用一行命令来从终端多次运行python脚本,并在终端中打印出结果。记住确切的代码或在线查找。像这样:

python3 test.py -#number of times

1 个答案:

答案 0 :(得分:1)

您始终可以使用seq和xargs和管道连续运行该程序x次。

seq number_of_times_to_run | xargs -Iz python your_program.py

或者,您可以使用for循环:

for i in {1..2}; do python your_program.py; done
相关问题