我有以下功能:爲什麼python返回None對象?
def isEmptyRet(self, cmdr, overIterate):
//some code which changes the cmdr object
if (some condition):
//some code
else:
print("got to this point")
print(cmdr)
return cmdr
控制檯打印如下:
got to this point
{'ap': {'file
//and some other parameters in JSON
}}}
這個功能是通過下面的函數調用:現在
def mod(self, tg):
//some code
cmdr = self.local_client.cmd(
tg, func
)
//some code..
cmdr = self.isEmptyRet(cmdr, False)
print(cmdr)
,控制檯打印: None
但功能isEmptyRet
返回對象,它不是無(如我們在控制檯中看到的)。
可能是什麼原因?
不,只有當它在'else'塊返回的東西。假設你在'if'塊中沒有return語句。 – 2014-09-02 13:08:17
它打印「到了這一點」? – Don 2014-09-02 13:08:22
@Don是的,它打印.. – 2014-09-02 13:09:01