我想让我的树莓派说出这个打印命令
print label + " is " + spos + " and the distance is " + str(distance) + "cm"
其中包含三个变量。这是我在 shell 中使用的命令,我需要在 python 中使用
$espeak -s110 "label + " is " + spos + " and the distance is " + str(distance) + "cm"" --stdout | aplay -D sysdefault:CARD=2
我已经用 os.system 试过了,因为我不熟悉subprocess
命令。
os.system('espeak -s110 "'label' + is + 'spos' + and the distance is + 'str(distance)' + cm" --stdout | aplay -D sysdefault:CARD=2')
我收到无效的语法错误。我已经尝试了它的每个版本,但无法使其正常工作。