Calling a non python program from python?

前端 未结 1 376
抹茶落季
抹茶落季 2020-12-19 15:10

I am currently struggling to call a non python program from a python script.

I have a ~1000 files that when passed through this C++ program will generate ~1000 outpu

相关标签:
1条回答
  • 2020-12-19 15:59

    You can use subprocess for that purpose:

    import os
    import subprocess
    
    cwd = os.getcwd()
    
    for i in os.listdir(cwd):
        if i.endswith('.ttp'):
            o = i + "-out"
            p = subprocess.call(["program_name", "-input", i, "-output", o])
    
    0 讨论(0)
提交回复
热议问题