有人知道怎么做吗?在
我试图得到一个函数的返回值。。但我不希望函数再次运行。这是语音识别,所以,每次它再次运行时,它都会尝试查看用户所说的话。我只需要保存变量。在
顺便说一下,我也不能使用全局变量。在
编辑:
def voiceRecognition(self):
<A bunch of voice recognition stuff here>
return whatUserSaid
我称之为代码:
^{pr2}$SPEECH和self的原因是b/c,它是类的一部分,我在另一个Python文件中调用它。现在它正在工作。。。我只需要返回变量whatUserSaid,而不需要重新运行函数来获取值。在
您可以使用一个类实例并记下该值。在
从你给定的代码来看,看起来你已经把它构建到一个类中了,所以我要做一些假设。在
这可以让你做如下事情:
^{pr2}$但我不知道你为什么要这么做。你不能把它保存到变量里吗?在
相关问题 更多 >
编程相关推荐