-1

Is there any way to run exe with inputs in Python? For example, there are two files, aaa.exe and bbb.dat. To run the analysis, I need to put those two files on DOS prompt like below. aaa.exe read the bbb.dat file. It there any command or workaround for this? I tried os.system and subprocess but I could not find a solution...

c:\Users\Program\Siimulation\Input> aaa.exe \bbb.dat

os.system("aaa.exe", "bbb.dat")

Progman
  • 16,827
  • 6
  • 33
  • 48

1 Answers1

0

You can o it by argparse. You can mark an argument as required by passing required=True to add_argument.

import argparse
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument("foo", ..., required=True)
parser.parse_args()

or you can use "sys"

import sys
len( sys.argv ) > 1