更新时间:2022-10-19 09:50:54
Functions always return something (at least None
, when no return-statement was reached during execution and the end of the function is reached).
Another case is when they are interrupted by exceptions.
In this case exception handling will "dominate over the stack" and you will return to the appropriate except
or get some nasty error :)
Regarding your problem I must say there are two possibilities: Either you have something to return or you do not have.
None
will tell the caller that this was the case (
There is no better way to tell the caller that "nothing" is returned then by None
, so check for it and you will be fine)