Python 仅将我的字符串的第一个单词传递给子进程

Python only passing the first word of my string to subprocess

所以我学习了一个星期 python,如果这很明显,我深表歉意,谁能告诉我为什么当我调用以下函数时我只得到我句子的第一个单词传递给 espeak 但是它下面的打印命令打印了整个东西?如果我将子进程调用中的 +x 替换为我希望它工作正常的文本,是否有一些我缺少的格式更改,比如以某种方式使我的变量成为字符串?

def speech(text):
    import subprocess
    x = text
    subprocess.call('espeak '+x, shell=True)
    print x

def exit():
    speech("Goodbye Slacker")

避免使用 shell=True(因为 security risk, and properly quoting the text 可能很麻烦)。相反,使用 shell=False 并在列表中传递参数:

subprocess.call(['espeak', x], shell=False)