1. 案例 v_list = [ 1 , 2 , 3 ] def func1 ( v_list ): yield from v_list for a in func1 ( v_list ): print ( a ) 2. 输出结果 H:\Web项目\PythonStudy\venv\Scripts\python.exe H:/Web项目/PythonStudy/study_test/yeild.py 1 2 3 Process fini
1. 案例
v_list = [1,2,3]def func1(v_list):
yield from v_list
for a in func1(v_list):
print(a)
2. 输出结果
H:\Web项目\PythonStudy\venv\Scripts\python.exe H:/Web项目/PythonStudy/study_test/yeild.py1
2
3
Process finished with exit code 0