Jor*_*dan 1 python yield generator
在生成器函数中,如何确定它是否已经产生了什么?
def my_generator(stuff):
# complex logic that interprets stuff and may or may not yield anything
# I only want to yield this if nothing has been yielded yet.
yield 'Nothing could be done with the input.'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88 次 |
| 最近记录: |