場景:我想依次執(zhí)行多個python的腳本凤价,我不想一個一個的執(zhí)行,于是我想到批處理
如在文件下有以下文件:
test*.py的內容大致如下:
[ZPJ@K10 Test]$ cat test1.py
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #-*- coding: UTF-8 -*-
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?print '測試2運行'
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? for i in range(6,10):
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?print i
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? print '測試2結束'
run.sh是我寫的批處理腳本: ? ?該腳本路徑:/home/ZPJ/mycode/summary/Test
[ZPJ@K10 Test]$ cat run.sh
? ? ? ? ? ? ? ? ? ? ? ? ? ?#!/bin/bash/python
? ? ? ? ? ? ? ? ? ? ? ? ? ?echo 'run program start' ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? python test.py ? ? ? ? ? ? ? ? ? ? ? ? ?#執(zhí)行腳本test.py
? ? ? ? ? ? ? ? ? ? ? ? ? ? python test1.py ? ? ? ? ? ? ? ? ? ? ? #執(zhí)行腳本test1.py
? ? ? ? ? ? ? ? ? ? ? ? ? ? python test2.py ? ? ? ? ? ? ? ? ? ? ? #執(zhí)行腳本test2.py
? ? ? ? ? ? ? ? ? ? ? ? ? ? python test3.py ? ? ? ? ? ? ? ? ? ? ? ? #執(zhí)行腳本test3.py
? ? ? ? ? ? ? ? ? ? ? ? ? ? echo 'run program finish
這只是一個初級的批處理命令教沾,其實可以將該命令寫成一個循環(huán),這樣里面再有python腳本的話唠帝,就不用手動改了!
參考該文章: http://blog.csdn.net/chenguolinblog/article/details/12655961