I need to run an application (binary file) and pass arguments using a Python code. Some arguments represent strings got during Python file processing.
for i in range ( len ( files ) ) :
subprocess.call(["test.exe", files[i]]) //How to pass the argument files[i]
Thanks...
Updated question:
Maybe I do not understand passing arguments in Python 3. A code without parameters runs OK
args = ['test. exe']
subprocess.call(args)
However the code with parameter causes an error:
args = ['test. exe']
subprocess.call(args, '-f') //Error
Error:
Error File "C:\Python32\lib\subprocess.py", line 467, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python32\lib\subprocess.py", line 652, in __init__
raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer
解决方案args = ['test. exe']
subprocess.call(args, '-f') //Error
should be:
args = ['test.exe', '-f']
subprocess.call(args)
The command line argument should all be inside a single list for the first parameter of subprocess.call. The second argument to call is bufsize, which is supposed to be an integer (hence why you get the error you do)