2013-02-04 51 views

回答

0

我不認爲這篇文章值得反對投票。但是從現在開始,我會建議OP自己去尋找一個解決方案,然後如果你在堆棧溢出中找不到答案帖子!

from subprocess import call 

with open("somefile.txt", 'r') as f: 
    some_files_to_run = [line.split('\n')[0] for line in f.readlines()] 
    for file_to_run in some_files_to_run: 
     call(["python", file_to_run]) 
2

我想你應該參考下面:

Calling an external command in Python

  1. 第一步

讀取命令文件中的所有行獲取python腳本文件名和參數列表 ,如:「C:\ hello.py和論證:單詞」

  • 第二步
  • 叫他們在下面的代碼風格

    from subprocess import call 
    call(["python C:\hello.py", "word"]) 
    ......