{"id":697,"date":"2026-07-15T16:58:10","date_gmt":"2026-07-15T08:58:10","guid":{"rendered":"https:\/\/mitongxue.cn\/?p=697"},"modified":"2026-07-15T16:58:10","modified_gmt":"2026-07-15T08:58:10","slug":"python-yield-%e6%b7%b1%e5%ba%a6%e8%a7%a3%e6%9e%90%ef%bc%9a%e9%98%bb%e5%a1%9e%e3%80%81%e5%bc%82%e6%ad%a5%e4%b8%8e%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%9a%84%e8%bf%b7%e6%80%9d","status":"publish","type":"post","link":"https:\/\/mitongxue.cn\/index.php\/2026\/07\/15\/python-yield-%e6%b7%b1%e5%ba%a6%e8%a7%a3%e6%9e%90%ef%bc%9a%e9%98%bb%e5%a1%9e%e3%80%81%e5%bc%82%e6%ad%a5%e4%b8%8e%e5%a4%9a%e7%ba%bf%e7%a8%8b%e7%9a%84%e8%bf%b7%e6%80%9d\/","title":{"rendered":"Python yield \u6df1\u5ea6\u89e3\u6790\uff1a\u963b\u585e\u3001\u5f02\u6b65\u4e0e\u591a\u7ebf\u7a0b\u7684\u8ff7\u601d"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728 Python \u7684\u9ad8\u9636\u7f16\u7a0b\u4e2d\uff0c<code>yield<\/code>&nbsp;\u5173\u952e\u5b57\u65e0\u7591\u662f\u6700\u5177\u8868\u73b0\u529b\u3001\u4e5f\u6700\u5bb9\u6613\u88ab\u8bef\u89e3\u7684\u7279\u6027\u4e4b\u4e00\u3002\u8bb8\u591a\u5f00\u53d1\u8005\u5728\u63a5\u89e6\u751f\u6210\u5668\uff08Generator\uff09\u548c\u534f\u7a0b\u65f6\uff0c\u5e38\u5e38\u4f1a\u5bf9\u5b83\u4ea7\u751f\u7591\u95ee\uff1a<code>yield<\/code>&nbsp;\u4f1a\u963b\u585e\u4e3b\u7ebf\u7a0b\u5417\uff1f\u5b83\u662f\u5f02\u6b65\u7684\u5417\uff1f\u5b83\u548c\u591a\u7ebf\u7a0b\u6709\u4ec0\u4e48\u5173\u7cfb\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u672c\u6587\u5c06\u62e8\u5f00\u8fd9\u4e9b\u8ff7\u96fe\uff0c\u5e26\u4f60\u6df1\u5165\u7406\u89e3&nbsp;<code>yield<\/code>&nbsp;\u7684\u5e95\u5c42\u673a\u5236\u3001\u771f\u5b9e\u884c\u4e3a\u4ee5\u53ca\u5b83\u5728\u73b0\u4ee3 Python \u5f02\u6b65\u7f16\u7a0b\u4e2d\u7684\u6f14\u8fdb\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e00\u3001 \u6838\u5fc3\u672c\u8d28\uff1a<\/strong><code>yield<\/code><strong>&nbsp;\u5230\u5e95\u662f\u4ec0\u4e48\uff1f<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u7406\u89e3&nbsp;<code>yield<\/code>\uff0c\u9996\u5148\u8981\u660e\u786e\u5b83\u7684\u6838\u5fc3\u4f5c\u7528\uff1a<strong>\u5b83\u5c06\u4e00\u4e2a\u666e\u901a\u7684\u51fd\u6570\u201c\u5347\u7ea7\u201d\u4e3a\u751f\u6210\u5668\u51fd\u6570\uff08Generator Function\uff09<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u4f60\u8c03\u7528\u4e00\u4e2a\u5305\u542b&nbsp;<code>yield<\/code>&nbsp;\u7684\u51fd\u6570\u65f6\uff0c\u51fd\u6570\u4f53\u5185\u7684\u4ee3\u7801<strong>\u5e76\u4e0d\u4f1a\u7acb\u5373\u6267\u884c<\/strong>\uff0c\u800c\u662f\u8fd4\u56de\u4e00\u4e2a\u751f\u6210\u5668\u5bf9\u8c61\u3002\u5f53\u4f60\u901a\u8fc7&nbsp;<code>next()<\/code>&nbsp;\u6216&nbsp;<code>for<\/code>&nbsp;\u5faa\u73af\u53bb\u8fed\u4ee3\u8fd9\u4e2a\u751f\u6210\u5668\u65f6\uff0c\u51fd\u6570\u624d\u4f1a\u6267\u884c\u5230\u9047\u5230\u7b2c\u4e00\u4e2a&nbsp;<code>yield<\/code>&nbsp;\u8bed\u53e5\u3002\u6b64\u65f6\uff0c<code>yield<\/code>&nbsp;\u4f1a\u505a\u4e24\u4ef6\u4e8b\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u4ea7\u51fa\uff08Yield\uff09\u4e00\u4e2a\u503c<\/strong>\u7ed9\u8c03\u7528\u65b9\u3002<\/li>\n\n\n\n<li><strong>\u6302\u8d77\uff08Suspend\uff09\u5f53\u524d\u51fd\u6570\u7684\u6267\u884c\u72b6\u6001<\/strong>\uff08\u5305\u62ec\u5c40\u90e8\u53d8\u91cf\u3001\u6307\u4ee4\u6307\u9488\u7b49\uff09\uff0c\u5e76\u5c06\u63a7\u5236\u6743\u4ea4\u8fd8\u7ed9\u8c03\u7528\u65b9\u3002<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0b\u4e00\u6b21\u8c03\u7528&nbsp;<code>next()<\/code>&nbsp;\u65f6\uff0c\u51fd\u6570\u4f1a\u4ece\u4e0a\u6b21&nbsp;<code>yield<\/code>&nbsp;\u6682\u505c\u7684\u5730\u65b9\u7ee7\u7eed\u6267\u884c\uff0c\u76f4\u5230\u9047\u5230\u4e0b\u4e00\u4e2a&nbsp;<code>yield<\/code>&nbsp;\u6216\u51fd\u6570\u7ed3\u675f\u3002\u8fd9\u79cd\u201c\u5206\u6bb5\u8fd4\u56de\u201d\u548c\u201c\u72b6\u6001\u4fdd\u6301\u201d\u7684\u7279\u6027\uff0c\u662f&nbsp;<code>yield<\/code>&nbsp;\u6700\u5f3a\u5927\u7684\u5730\u65b9\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e8c\u3001 \u8ff7\u601d\u7834\u89e3\uff1a<\/strong><code>yield<\/code><strong>&nbsp;\u4f1a\u963b\u585e\u4e3b\u7ebf\u7a0b\u5417\uff1f<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7ed3\u8bba\u662f\uff1a<code>yield<\/code>&nbsp;\u672c\u8eab\u4e0d\u4f1a\u963b\u585e\u4e3b\u7ebf\u7a0b\uff0c\u4e5f\u4e0d\u4f1a\u91ca\u653e\u4e3b\u7ebf\u7a0b\u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u662f\u4e00\u4e2a\u6781\u5176\u5e38\u89c1\u7684\u8bef\u89e3\u3002<code>yield<\/code>&nbsp;\u5b9e\u73b0\u7684\u662f\u4e00\u79cd<strong>\u534f\u4f5c\u5f0f\uff08Cooperative\uff09\u7684\u6682\u505c\u4e0e\u6062\u590d<\/strong>\uff0c\u6574\u4e2a\u8fc7\u7a0b\u5b8c\u5168\u5728\u7528\u6237\u6001\u3001\u5355\u7ebf\u7a0b\u5185\u5b8c\u6210\uff0c\u4e0d\u6d89\u53ca\u64cd\u4f5c\u7cfb\u7edf\u5c42\u9762\u7684\u7ebf\u7a0b\u8c03\u5ea6\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4e0d\u963b\u585e CPU<\/strong>\uff1a\u5f53\u6267\u884c\u5230\u00a0<code>yield<\/code>\u00a0\u65f6\uff0c\u51fd\u6570\u53ea\u662f\u4fdd\u5b58\u4e86\u6808\u5e27\u548c\u6267\u884c\u72b6\u6001\uff0c\u7136\u540e\u8fd4\u56de\u3002\u5b83\u4e0d\u4f1a\u5360\u7528 CPU \u53bb\u201c\u6b7b\u7b49\u201d\u67d0\u4e2a\u7ed3\u679c\u3002<\/li>\n\n\n\n<li><strong>\u4e0d\u91ca\u653e\u4e3b\u7ebf\u7a0b<\/strong>\uff1a<code>yield<\/code>\u00a0\u4e0d\u4f1a\u89e6\u53d1 GIL\uff08\u5168\u5c40\u89e3\u91ca\u5668\u9501\uff09\u7684\u91ca\u653e\uff0c\u4e5f\u4e0d\u4f1a\u8ba9\u51fa\u63a7\u5236\u6743\u7ed9\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u3002\u4e3b\u7ebf\u7a0b\u59cb\u7ec8\u7531 Python \u89e3\u91ca\u5668\u63a7\u5236\u3002<code>yield<\/code>\u00a0\u53ea\u662f\u628a\u63a7\u5236\u6743\u4ece\u201c\u751f\u6210\u5668\u51fd\u6570\u201d\u4ea4\u8fd8\u7ed9\u4e86\u201c\u8c03\u7528\u751f\u6210\u5668\u7684\u4ee3\u7801\u201d\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5927\u767d\u8bdd\u89e3\u91ca<\/strong>\uff1a<code>yield<\/code>&nbsp;\u5c31\u50cf\u662f\u4f60\u5728\u5de5\u4f5c\uff08\u6267\u884c\u51fd\u6570\uff09\u65f6\uff0c\u9047\u5230\u4e00\u4e2a\u9700\u8981\u7b49\u5f85\u7684\u8282\u70b9\uff0c\u4f60\u628a\u624b\u5934\u7684\u5de5\u4f5c\u72b6\u6001\u8bb0\u5728\u7b14\u8bb0\u672c\u4e0a\uff08\u4fdd\u5b58\u72b6\u6001\uff09\uff0c\u7136\u540e\u8f6c\u8eab\u53bb\u5904\u7406\u522b\u7684\u4e8b\u60c5\uff08\u4ea4\u8fd8\u63a7\u5236\u6743\uff09\u3002\u7b49\u4f60\u5904\u7406\u5b8c\u522b\u7684\u4e8b\uff0c\u518d\u56de\u6765\u770b\u7b14\u8bb0\u672c\u63a5\u7740\u5e72\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u4f60\u5e76\u6ca1\u6709\u79bb\u5f00\u529e\u516c\u5ba4\uff08\u4e3b\u7ebf\u7a0b\uff09\uff0c\u4e5f\u6ca1\u6709\u628a\u529e\u516c\u5ba4\u8ba9\u7ed9\u522b\u4eba\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e09\u3001&nbsp;<\/strong><code>yield<\/code><strong>&nbsp;\u662f\u5f02\u6b65\u7684\u5417\uff1f<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7ed3\u8bba\u662f\uff1a\u539f\u751f\u7684&nbsp;<code>yield<\/code>&nbsp;\u662f\u540c\u6b65\u7684\uff0c\u4f46\u5b83\u662f\u73b0\u4ee3\u5f02\u6b65\u7f16\u7a0b\u7684\u57fa\u77f3\u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>yield<\/code>&nbsp;\u672c\u8eab\u5e76\u4e0d\u5177\u5907\u5904\u7406 I\/O \u5bc6\u96c6\u578b\u4efb\u52a1\uff08\u5982\u7f51\u7edc\u8bf7\u6c42\u3001\u6587\u4ef6\u8bfb\u5199\uff09\u7684\u5f02\u6b65\u80fd\u529b\u3002\u5982\u679c\u4f60\u5728\u751f\u6210\u5668\u91cc\u5199\u4e86\u4e00\u4e2a\u8017\u65f6\u7684\u540c\u6b65\u64cd\u4f5c\uff08\u5982&nbsp;<code>time.sleep(5)<\/code>\uff09\uff0c\u7a0b\u5e8f\u4f9d\u7136\u4f1a\u7ed3\u7ed3\u5b9e\u5b9e\u5730\u5361\u4f4f 5 \u79d2\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7136\u800c\uff0c<code>yield<\/code>&nbsp;\u7684\u5386\u53f2\u5730\u4f4d\u6781\u5176\u91cd\u8981\u3002\u5728 Python 3.5 \u4e4b\u524d\uff0cPython \u7684\u534f\u7a0b\uff08Coroutine\uff09\u6b63\u662f\u57fa\u4e8e&nbsp;<code>yield<\/code>&nbsp;\u5b9e\u73b0\u7684\u3002\u5f00\u53d1\u8005\u901a\u8fc7&nbsp;<code>yield<\/code>&nbsp;\u6302\u8d77\u51fd\u6570\uff0c\u914d\u5408\u5916\u90e8\u7684\u4e8b\u4ef6\u5faa\u73af\uff08Event Loop\uff09\u6765\u5b9e\u73b0\u201c\u4f2a\u5f02\u6b65\u201d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u73b0\u4ee3 Python \u7684\u6f14\u8fdb<\/strong>\uff1a<br>\u4ece Python 3.5 \u5f00\u59cb\uff0c\u5b98\u65b9\u5f15\u5165\u4e86&nbsp;<code>async def<\/code>&nbsp;\u548c&nbsp;<code>await<\/code>&nbsp;\u8bed\u6cd5\u3002<code>await<\/code>&nbsp;\u5728\u5e95\u5c42\u672c\u8d28\u4e0a\u53ef\u4ee5\u7406\u89e3\u4e3a&nbsp;<code>yield from<\/code>&nbsp;\u7684\u589e\u5f3a\u7248\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u679c\u4f60\u60f3\u5b9e\u73b0\u771f\u6b63\u7684\u975e\u963b\u585e\u5f02\u6b65 I\/O\uff0c<strong>\u4e0d\u8981\u518d\u4f7f\u7528\u00a0<code>yield<\/code><\/strong>\uff0c\u800c\u5e94\u8be5\u4f7f\u7528\u00a0<code>async\/await<\/code>\u00a0\u914d\u5408\u00a0<code>asyncio<\/code>\u00a0\u5e93\u3002<\/li>\n\n\n\n<li><code>await<\/code>\u00a0\u4f1a\u5728\u7b49\u5f85 I\/O \u65f6\u771f\u6b63\u6302\u8d77\u5f53\u524d\u534f\u7a0b\uff0c\u5e76\u5c06\u63a7\u5236\u6743\u4ea4\u8fd8\u7ed9\u4e8b\u4ef6\u5faa\u73af\uff0c\u8ba9\u4e8b\u4ef6\u5faa\u73af\u53bb\u6267\u884c\u5176\u4ed6\u4efb\u52a1\uff0c\u4ece\u800c\u5145\u5206\u5229\u7528 CPU \u8d44\u6e90\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u56db\u3001&nbsp;<\/strong><code>yield<\/code><strong>&nbsp;\u4e0e\u591a\u7ebf\u7a0b\u7684\u5173\u7cfb<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7ed3\u8bba\u662f\uff1a<code>yield<\/code>&nbsp;\u4e0e\u591a\u7ebf\u7a0b\u662f\u4e24\u4e2a\u5b8c\u5168\u4e0d\u540c\u7ef4\u5ea6\u7684\u6982\u5ff5\u3002<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u591a\u7ebf\u7a0b<\/strong>\uff1a\u662f\u64cd\u4f5c\u7cfb\u7edf\u7ea7\u522b\u7684\u5e76\u53d1\u673a\u5236\u3002Python \u7684\u591a\u7ebf\u7a0b\u53d7\u9650\u4e8e GIL\uff0c\u540c\u4e00\u65f6\u523b\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u5728\u6267\u884c Python \u5b57\u8282\u7801\uff0c\u4e3b\u8981\u7528\u4e8e I\/O \u5bc6\u96c6\u578b\u4efb\u52a1\u7684\u5e76\u53d1\u3002<\/li>\n\n\n\n<li><strong><code>yield<\/code>\uff08\u751f\u6210\u5668\uff09<\/strong>\uff1a\u662f\u8bed\u8a00\u7ea7\u522b\u7684\u8bed\u6cd5\u7279\u6027\uff0c\u8fd0\u884c\u5728\u5355\u7ebf\u7a0b\u5185\u90e8\u3002\u5b83\u4e0d\u6d89\u53ca\u7ebf\u7a0b\u7684\u521b\u5efa\u3001\u9500\u6bc1\u548c\u4e0a\u4e0b\u6587\u5207\u6362\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5b83\u4eec\u53ef\u4ee5\u7ed3\u5408\u4f7f\u7528\u5417\uff1f<\/strong>&nbsp;\u53ef\u4ee5\uff0c\u4f46\u5404\u53f8\u5176\u804c\u3002\u4f60\u53ef\u4ee5\u5728\u4e00\u4e2a\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u7684\u67d0\u4e2a\u7ebf\u7a0b\u5185\u90e8\uff0c\u4f7f\u7528&nbsp;<code>yield<\/code>&nbsp;\u6765\u6784\u5efa\u4e00\u4e2a\u9ad8\u6548\u7684\u6570\u636e\u5904\u7406\u7ba1\u9053\uff1b\u6216\u8005\u4f7f\u7528&nbsp;<code>yield<\/code>&nbsp;\u6765\u5b9e\u73b0\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u3001\u5355\u7ebf\u7a0b\u5185\u7684\u7b80\u6613\u4efb\u52a1\u8c03\u5ea6\u5668\u3002\u4f46\u5728\u73b0\u4ee3\u5de5\u7a0b\u5b9e\u8df5\u4e2d\uff0c\u5904\u7406\u9ad8\u5e76\u53d1 I\/O \u4efb\u52a1\uff0c\u6211\u4eec\u66f4\u503e\u5411\u4e8e\u4f7f\u7528&nbsp;<code>asyncio<\/code>&nbsp;\u800c\u4e0d\u662f\u624b\u52a8\u7528&nbsp;<code>yield<\/code>&nbsp;\u53bb\u5199\u8c03\u5ea6\u5668\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u4e94\u3001&nbsp;<\/strong><code>yield<\/code><strong>&nbsp;\u7684\u73b0\u4ee3\u6700\u4f73\u5b9e\u8df5\uff1a\u60f0\u6027\u6570\u636e\u6d41<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u65e2\u7136&nbsp;<code>yield<\/code>&nbsp;\u4e0d\u8d1f\u8d23\u5f02\u6b65\u5e76\u53d1\uff0c\u90a3\u5b83\u73b0\u5728\u7684\u7528\u6b66\u4e4b\u5730\u5728\u54ea\u91cc\uff1f<strong>\u7b54\u6848\u662f\uff1a\u5185\u5b58\u53cb\u597d\u7684\u60f0\u6027\u6570\u636e\u6d41\u5904\u7406\u3002<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5904\u7406\u6d77\u91cf\u6570\u636e\u65f6\uff0c<code>yield<\/code>&nbsp;\u662f\u65e0\u53ef\u66ff\u4ee3\u7684\u795e\u5668\u3002\u4f8b\u5982\uff0c\u8bfb\u53d6\u4e00\u4e2a 10GB \u7684\u65e5\u5fd7\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def read_large_file(file_path):\n    with open(file_path, 'r') as file:\n        for line in file:\n            yield line.strip()  <em># \u6bcf\u6b21\u53ea\u4ea7\u51fa\u4e00\u884c\uff0c\u5185\u5b58\u5360\u7528\u6781\u4f4e<\/em>\n\n<em># \u6d41\u5f0f\u5904\u7406\uff0c\u6c38\u8fdc\u4e0d\u4f1a\u5185\u5b58\u6ea2\u51fa (OOM)<\/em>\nfor line in read_large_file('huge_log.txt'):\n    process(line)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f7f\u7528&nbsp;<code>return<\/code>&nbsp;\u914d\u5408\u5217\u8868\uff0c10GB \u7684\u6570\u636e\u4f1a\u77ac\u95f4\u6491\u7206\u5185\u5b58\uff1b\u800c\u4f7f\u7528&nbsp;<code>yield<\/code>\uff0c\u5185\u5b58\u6d88\u8017\u59cb\u7ec8\u4fdd\u6301\u5728\u6781\u4f4e\u7684\u6052\u5b9a\u6c34\u5e73\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u603b\u7ed3<\/strong><\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u963b\u585e\u4e0e\u7ebf\u7a0b<\/strong>\uff1a<code>yield<\/code>\u00a0\u662f\u534f\u4f5c\u5f0f\u7684\u6682\u505c\uff0c\u4e0d\u963b\u585e\u4e3b\u7ebf\u7a0b\uff0c\u4e5f\u4e0d\u91ca\u653e\u4e3b\u7ebf\u7a0b\uff0c\u5b8c\u5168\u5728\u5355\u7ebf\u7a0b\u7528\u6237\u6001\u8fd0\u884c\u3002<\/li>\n\n\n\n<li><strong>\u5f02\u6b65\u80fd\u529b<\/strong>\uff1a\u539f\u751f\u00a0<code>yield<\/code>\u00a0\u662f\u540c\u6b65\u7684\u3002\u8981\u5b9e\u73b0\u771f\u6b63\u7684\u5f02\u6b65 I\/O\uff0c\u8bf7\u4f7f\u7528\u00a0<code>async\/await<\/code>\u3002<\/li>\n\n\n\n<li><strong>\u591a\u7ebf\u7a0b<\/strong>\uff1a<code>yield<\/code>\u00a0\u5c5e\u4e8e\u5355\u7ebf\u7a0b\u5185\u7684\u63a7\u5236\u6d41\u62bd\u8c61\uff0c\u4e0e\u591a\u7ebf\u7a0b\u5e76\u53d1\u673a\u5236\u4e92\u4e0d\u5e72\u6270\u3002<\/li>\n\n\n\n<li><strong>\u6838\u5fc3\u4ef7\u503c<\/strong>\uff1a\u5728\u73b0\u4ee3 Python \u4e2d\uff0c<code>yield<\/code>\u00a0\u6700\u4f18\u96c5\u7684\u821e\u53f0\u662f\u6784\u5efa\u60f0\u6027\u5e8f\u5217\u3001\u5904\u7406\u5927\u6570\u636e\u6d41\u4ee5\u53ca\u89e3\u8026\u590d\u6742\u7684\u8fed\u4ee3\u903b\u8f91\u3002<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Python \u7684\u9ad8\u9636\u7f16\u7a0b\u4e2d\uff0cyield&#038;nbs..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52,14],"tags":[],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-python","category-back"],"featured_image_urls":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":""},"author_info":{"info":["\u9648 \u67d0\u4eba"]},"category_info":"<a href=\"https:\/\/mitongxue.cn\/index.php\/category\/back\/python\/\" rel=\"category tag\">Python<\/a> <a href=\"https:\/\/mitongxue.cn\/index.php\/category\/back\/\" rel=\"category tag\">\u540e\u7aef<\/a>","tag_info":"\u540e\u7aef","comment_count":"0","_links":{"self":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/comments?post=697"}],"version-history":[{"count":1,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/697\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/posts\/697\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/media?parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/categories?post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mitongxue.cn\/index.php\/wp-json\/wp\/v2\/tags?post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}