我有以下名为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
它有效。有什么问题?
答案 0 :(得分:0)
它告诉你bufsize must be an integer
。我猜你在脚本中为preset
设置的值不是整数(请记住0.0
是浮点数,而不是整数)。通过在函数中打印出来,快速检查您的参数是什么。