python怎么运行一个文件_如何在一个文件夹中一个接一个地运行多个python文件

I have around 20 python files.

Each time I run these files in the terminal this form one after another :

python a.py

python b.py

python c.py

python d.py

python e.py

python f.py

python g.py

.

.

.

(I have provided general file names here)

This process takes lot of time.

Is it possible to run these file together one after another through any script..?

If possible, then how..?

Please provide the code if possible...

I came to know through few sites that, using bash script we can do that..

I don't know how to implement it.

If you can suggest any other method, even that would be helpful.

EDITS:

And I need to generate report for each file using nosetests.

The problem I am facing with nosetests is that, it creates an HTML file with the name results.html.

Each time the report is created, the latest HTML file replaces the old HTML file. Beacuse the names are same.

So what I am doing now is, renaming the report each time i run the nosetests for a python file. Run the nosetests for second file, report gets generated, and rename it.. it goes on...

If somebody could tell me how I can overcome this, It would be helpful..

I am working on Ubuntu 14.04

解决方案

To run dynamically all the python scripts in a given folder YOUR_FOLDER, you could run bash script like:

#!/bin/bash

for py_file in $(find $YOUR_FOLDER -name *.py)

do

python $py_file

done

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值