在 Linux 上,我有以下名为 visca.py 的 python 源文件:
from subprocess import call
def recall(preset):
call(["visca-cli", "memory_recall", str(preset)])
我在 shell 中打开 python 解释器并导入 visca,然后我输入 visca.recall(0) 并得到
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "visca.py", line 13, in recall
subprocess.call(["visca-cli", "memory_recall", str(preset)]) File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait() File "/usr/lib/python2.7/subprocess.py", line 629, in __init__
raise TypeError("bufsize must be an integer") TypeError: bufsize must be an integer
但是,如果我直接在 python shell 中输入
>>> from subprocess import call
>>> call(["visca-cli", "memory_recall", "0"])
10 OK - no return value
0
有用。有什么问题?