我有以下功能:为什么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