16
我有我的Python程序這個功能:的Python語法錯誤:( 「 '迴歸' 裏面生成參數」)
@tornado.gen.engine
def check_status_changes(netid, sensid):
como_url = "".join(['http://131.114.52:44444/ztc?netid=', str(netid), '&sensid=', str(sensid), '&start=-5s&end=-1s'])
http_client = AsyncHTTPClient()
response = yield tornado.gen.Task(http_client.fetch, como_url)
if response.error:
self.error("Error while retrieving the status")
self.finish()
return error
for line in response.body.split("\n"):
if line != "":
#net = int(line.split(" ")[1])
#sens = int(line.split(" ")[2])
#stype = int(line.split(" ")[3])
value = int(line.split(" ")[4])
print value
return value
我知道
for line in response.body.split
是發電機。但是我會將值變量返回給調用該函數的處理程序。這可能嗎?我能怎麼做?
'yield value'。 – katrielalex 2013-04-04 11:02:12
已經嘗試過..但我得到了同樣的錯誤......我認爲這是不可能把一個返回到發電機... – sharkbait 2013-04-04 11:03:54
的'for'循環不是一臺發電機;整個功能是因爲你有一個'yield'語句。 – geoffspear 2013-04-04 11:05:37