Python中yield有什么作用?


yield有什么用?

例如下面这段代码:

def node._get_child_candidates(self, distance, min_dist, max_dist):
    if self._leftchild and distance - max_dist < self._median:
        yield self._leftchild
    if self._rightchild and distance + max_dist >= self._median:
        yield self._rightchild

Continue reading “Python中yield有什么作用?”

Advertisements