【发布时间】:2016-03-14 19:31:20
【问题描述】:
我是一名 PHP 开发人员,我曾经在 PHP 中使用 $_SERVER['QUERY_STRING'] 获取查询字符串。
Python 2.7 的语法是什么?
import web
import speech_recognition as sr
from os import path
urls = (
'/voice', 'Voice'
)
app = web.application(urls, globals())
class Voice:
def GET(self):
WAV_FILE = path.join(path.dirname(path.realpath("C:\Python27")),'wavfile.wav')
r = sr.Recognizer()
with sr.WavFile("C:\Python27\wavfile.wav") as source:
audio = r.record(source) # read the entire WAV file
output = r.recognize_google(audio)
return output
if __name__ == "__main__":
app.run()
【问题讨论】:
-
使用任何特定的框架?
-
不,更新了问题。
-
我认为对特定框架的回答是是。看起来您使用的是
web.py? -
我不知道 web.py。
-
您的代码包括
import web(其中isn't in the Python 2 standard library)和web.py教程中相同的urls/app = web.application(urls, globals())结构。如果您的代码真的看起来像这样,我很有信心它使用web.py。
标签: php python python-2.7 web.py