python应用软件怎么运行,如何在Python中使用参数运行应用程序?

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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值