{"id":1491,"date":"2025-02-09T10:11:02","date_gmt":"2025-02-09T02:11:02","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=1491"},"modified":"2025-02-09T10:11:03","modified_gmt":"2025-02-09T02:11:03","slug":"python%e5%bc%80%e5%8f%91%e4%b8%ad%e7%9a%84%e5%b8%b8%e8%a7%81%e8%af%af%e5%8c%ba%e5%8f%8a%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88%ef%bc%9a%e6%8f%90%e5%8d%87%e4%bb%a3%e7%a0%81%e8%b4%a8%e9%87%8f%e4%b8%8e","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/02\/09\/python%e5%bc%80%e5%8f%91%e4%b8%ad%e7%9a%84%e5%b8%b8%e8%a7%81%e8%af%af%e5%8c%ba%e5%8f%8a%e8%a7%a3%e5%86%b3%e6%96%b9%e6%a1%88%ef%bc%9a%e6%8f%90%e5%8d%87%e4%bb%a3%e7%a0%81%e8%b4%a8%e9%87%8f%e4%b8%8e\/","title":{"rendered":"Python\u5f00\u53d1\u4e2d\u7684\u5e38\u89c1\u8bef\u533a\u53ca\u89e3\u51b3\u65b9\u6848\uff1a\u63d0\u5347\u4ee3\u7801\u8d28\u91cf\u4e0e\u6027\u80fd"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u5728\u5e94\u7528 Python \u65f6\uff0c\u5f00\u53d1\u8005\u5e38\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8bef\u533a\uff0c\u7406\u89e3\u5e76\u907f\u514d\u8fd9\u4e9b\u8bef\u533a\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u7f16\u7a0b\u5e76\u51cf\u5c11\u8c03\u8bd5\u548c\u9519\u8bef\u7684\u65f6\u95f4\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 Python \u5f00\u53d1\u8bef\u533a\u53ca\u5176\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>\u8bef\u533a\uff1a\u5ffd\u89c6 Python \u7684\u7f29\u8fdb\u89c4\u5219<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u662f\u57fa\u4e8e\u7f29\u8fdb\u6765\u6807\u8bc6\u4ee3\u7801\u5757\u7684\uff0c\u5f88\u591a\u5f00\u53d1\u8005\u4f1a\u56e0\u4e3a\u5fd8\u8bb0\u7f29\u8fdb\u6216\u7f29\u8fdb\u4e0d\u4e00\u81f4\u800c\u5bfc\u81f4\u9519\u8bef\u3002\u8fd9\u901a\u5e38\u4f1a\u5bfc\u81f4 <code>IndentationError<\/code> \u6216\u903b\u8f91\u9519\u8bef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u786e\u4fdd\u4ee3\u7801\u5757\u5185\u7684\u6240\u6709\u884c\u90fd\u4f7f\u7528\u76f8\u540c\u6570\u91cf\u7684\u7a7a\u683c\u6216\u5236\u8868\u7b26\uff08\u63a8\u8350\u4f7f\u7528\u56db\u4e2a\u7a7a\u683c\uff09\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528\u73b0\u4ee3 IDE\uff08\u5982 PyCharm\u3001VS Code \u7b49\uff09\u6765\u81ea\u52a8\u5b8c\u6210\u7f29\u8fdb\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u8bef\u533a\uff1a\u4f7f\u7528\u53ef\u53d8\u7c7b\u578b\u4f5c\u4e3a\u9ed8\u8ba4\u53c2\u6570<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Python \u51fd\u6570\u5b9a\u4e49\u4e2d\u4f7f\u7528\u53ef\u53d8\u7c7b\u578b\uff08\u5982\u5217\u8868\u3001\u5b57\u5178\uff09\u4f5c\u4e3a\u9ed8\u8ba4\u53c2\u6570\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e0d\u53ef\u9884\u89c1\u7684\u884c\u4e3a\u3002\u7531\u4e8e Python \u7684\u9ed8\u8ba4\u53c2\u6570\u53ea\u4f1a\u5728\u51fd\u6570\u5b9a\u4e49\u65f6\u521b\u5efa\u4e00\u6b21\uff0c\u56e0\u6b64\u5728\u51fd\u6570\u8c03\u7528\u671f\u95f4\u5bf9\u8fd9\u4e9b\u9ed8\u8ba4\u53c2\u6570\u7684\u4fee\u6539\u4f1a\u5f71\u54cd\u540e\u7eed\u7684\u8c03\u7528\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u4e0d\u53ef\u53d8\u7c7b\u578b\uff08\u5982 <code>None<\/code>\uff09\u4f5c\u4e3a\u9ed8\u8ba4\u53c2\u6570\uff0c\u5e76\u5728\u51fd\u6570\u5185\u90e8\u521d\u59cb\u5316\u53ef\u53d8\u7c7b\u578b\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>def my_func(a=None):\n    if a is None:\n        a = &#91;]\n    a.append(1)\n    return a<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>\u8bef\u533a\uff1a\u4e0d\u7406\u89e3 Python \u7684\u5f15\u7528\u673a\u5236<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u4e2d\u7684\u53d8\u91cf\u662f\u5f15\u7528\u7c7b\u578b\uff0c\u5f53\u4f60\u5c06\u4e00\u4e2a\u53d8\u91cf\u8d4b\u503c\u7ed9\u53e6\u4e00\u4e2a\u53d8\u91cf\u65f6\uff0c\u5b9e\u9645\u4e0a\u662f\u5c06\u5f15\u7528\u4f20\u9012\u7ed9\u5b83\uff0c\u800c\u4e0d\u662f\u590d\u5236\u5bf9\u8c61\u3002\u8fd9\u5bfc\u81f4\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u53ef\u80fd\u4f1a\u51fa\u73b0\u610f\u5916\u7684\u4fee\u6539\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>copy<\/code> \u6a21\u5757\u6765\u521b\u5efa\u5bf9\u8c61\u7684\u526f\u672c\uff0c\u907f\u514d\u4e0d\u5c0f\u5fc3\u4fee\u6539\u539f\u59cb\u5bf9\u8c61\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>import copy\n\na = &#91;1, 2, 3]\nb = copy.deepcopy(a)  # \u521b\u5efa a \u7684\u6df1\u62f7\u8d1d<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>\u8bef\u533a\uff1a\u4e0d\u4e86\u89e3\u5168\u5c40\u548c\u5c40\u90e8\u53d8\u91cf\u7684\u4f5c\u7528\u57df<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u4e2d\u7684\u53d8\u91cf\u4f5c\u7528\u57df\u53ef\u80fd\u4f1a\u8ba9\u5f00\u53d1\u8005\u8ff7\u60d1\uff0c\u7279\u522b\u662f\u5982\u4f55\u5728\u51fd\u6570\u5185\u4fee\u6539\u5168\u5c40\u53d8\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>global<\/code> \u5173\u952e\u5b57\u6765\u4fee\u6539\u5168\u5c40\u53d8\u91cf\u3002<\/li>\n\n\n\n<li>\u907f\u514d\u5728\u51fd\u6570\u4e2d\u65e0\u610f\u4e2d\u4fee\u6539\u5168\u5c40\u53d8\u91cf\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>x = 10\n\ndef modify():\n    global x\n    x = 20\n\nmodify()\nprint(x)  # \u8f93\u51fa 20<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>\u8bef\u533a\uff1a\u6ee5\u7528 <code>import *<\/code><\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528 <code>from module import *<\/code> \u4f1a\u5c06\u6a21\u5757\u4e2d\u7684\u6240\u6709\u5bf9\u8c61\u5bfc\u5165\u5f53\u524d\u4f5c\u7528\u57df\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u547d\u540d\u51b2\u7a81\u6216\u4ee3\u7801\u96be\u4ee5\u7ef4\u62a4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u660e\u786e\u5bfc\u5165\u9700\u8981\u7684\u529f\u80fd\uff0c\u907f\u514d\u4f7f\u7528 <code>import *<\/code>\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 <code>as<\/code> \u5173\u952e\u5b57\u4e3a\u6a21\u5757\u6216\u51fd\u6570\u8d77\u522b\u540d\uff0c\u589e\u5f3a\u4ee3\u7801\u53ef\u8bfb\u6027\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>import math as m\nprint(m.pi)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>\u8bef\u533a\uff1a\u4e0d\u8003\u8651 Python \u7684\u6027\u80fd\u95ee\u9898<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u867d\u7136 Python \u662f\u4e00\u79cd\u9ad8\u5c42\u8bed\u8a00\uff0c\u4f46\u5b83\u7684\u6267\u884c\u901f\u5ea6\u6bd4 C\u3001C++ \u7b49\u5e95\u5c42\u8bed\u8a00\u8981\u6162\u3002\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u6216\u9700\u8981\u9ad8\u6027\u80fd\u7684\u5e94\u7528\u65f6\uff0c\u6709\u65f6\u4f1a\u5ffd\u7565\u4f18\u5316\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u66f4\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u6216\u6807\u51c6\u5e93\u51fd\u6570\uff0c\u5b83\u4eec\u901a\u5e38\u7ecf\u8fc7\u4f18\u5316\u3002<\/li>\n\n\n\n<li>\u5728\u9700\u8981\u9ad8\u6027\u80fd\u65f6\uff0c\u8003\u8651\u4f7f\u7528 Cython \u6216\u5c06\u6027\u80fd\u5173\u952e\u90e8\u5206\u7528 C\/C++ \u7f16\u5199\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">7. <strong>\u8bef\u533a\uff1a\u8fc7\u5ea6\u4f9d\u8d56 <code>try\/except<\/code> \u6765\u5904\u7406\u6240\u6709\u9519\u8bef<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u867d\u7136 <code>try\/except<\/code> \u8bed\u53e5\u7528\u4e8e\u6355\u6349\u5f02\u5e38\uff0c\u4f46\u5982\u679c\u8fc7\u5ea6\u4f9d\u8d56\u5b83\u4eec\u6765\u6355\u6349\u6240\u6709\u9519\u8bef\uff0c\u800c\u4e0d\u662f\u8fdb\u884c\u5408\u7406\u7684\u9519\u8bef\u5904\u7406\u6216\u9884\u9632\uff0c\u53ef\u80fd\u4f1a\u63a9\u76d6\u4ee3\u7801\u4e2d\u7684\u6f5c\u5728\u95ee\u9898\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u53ea\u6355\u83b7\u4f60\u9884\u671f\u7684\u7279\u5b9a\u5f02\u5e38\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 <code>else<\/code> \u548c <code>finally<\/code> \u8fdb\u884c\u6709\u6548\u7684\u9519\u8bef\u5904\u7406\u548c\u8d44\u6e90\u6e05\u7406\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>try:\n    x = 10 \/ 0\nexcept ZeroDivisionError:\n    print(\"\u4e0d\u80fd\u9664\u4ee5\u96f6\")<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">8. <strong>\u8bef\u533a\uff1a\u8bef\u7528 <code>==<\/code> \u548c <code>is<\/code><\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>==<\/code> \u6bd4\u8f83\u7684\u662f\u5bf9\u8c61\u7684\u503c\uff0c\u800c <code>is<\/code> \u6bd4\u8f83\u7684\u662f\u5bf9\u8c61\u7684\u8eab\u4efd\uff08\u5373\u5185\u5b58\u5730\u5740\uff09\u3002\u6709\u65f6\u5f00\u53d1\u8005\u4f1a\u9519\u8bef\u5730\u4f7f\u7528 <code>is<\/code> \u6765\u6bd4\u8f83\u503c\u76f8\u7b49\uff0c\u5bfc\u81f4\u610f\u5916\u7684\u7ed3\u679c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5bf9\u4e8e\u503c\u76f8\u7b49\u7684\u6bd4\u8f83\uff0c\u4f7f\u7528 <code>==<\/code>\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u5bf9\u8c61\u8eab\u4efd\u7684\u6bd4\u8f83\uff08\u4f8b\u5982\u5224\u65ad\u4e24\u4e2a\u5bf9\u8c61\u662f\u5426\u4e3a\u540c\u4e00\u4e2a\u5bf9\u8c61\uff09\uff0c\u4f7f\u7528 <code>is<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>a = &#91;1, 2, 3]\nb = &#91;1, 2, 3]\nprint(a == b)  # True\uff0c\u503c\u76f8\u7b49\nprint(a is b)  # False\uff0c\u6307\u5411\u4e0d\u540c\u5bf9\u8c61<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">9. <strong>\u8bef\u533a\uff1a\u5ffd\u89c6 Python \u7684\u5783\u573e\u56de\u6536\u673a\u5236<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u4f7f\u7528\u81ea\u52a8\u5783\u573e\u56de\u6536\u673a\u5236\uff08\u5373\u5f15\u7528\u8ba1\u6570\u548c\u5783\u573e\u56de\u6536\u5668\uff09\uff0c\u4f46\u4e00\u4e9b\u5f00\u53d1\u8005\u53ef\u80fd\u6ca1\u6709\u610f\u8bc6\u5230\u8fd9\u4e00\u70b9\uff0c\u5bfc\u81f4\u5185\u5b58\u6cc4\u6f0f\u6216\u6027\u80fd\u95ee\u9898\uff0c\u5c24\u5176\u662f\u5728\u5faa\u73af\u5f15\u7528\u7684\u60c5\u51b5\u4e0b\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7406\u89e3 Python \u7684\u5783\u573e\u56de\u6536\u673a\u5236\uff0c\u5e76\u907f\u514d\u9020\u6210\u5faa\u73af\u5f15\u7528\u3002<\/li>\n\n\n\n<li>\u4f7f\u7528 <code>gc<\/code> \u6a21\u5757\u624b\u52a8\u63a7\u5236\u5783\u573e\u56de\u6536\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>import gc\n\ngc.collect()  # \u5f3a\u5236\u8fdb\u884c\u5783\u573e\u56de\u6536<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">10. <strong>\u8bef\u533a\uff1a\u4e0d\u719f\u6089 Python \u7684\u8fed\u4ee3\u5668\u4e0e\u751f\u6210\u5668<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u7684\u8fed\u4ee3\u5668\u548c\u751f\u6210\u5668\u53ef\u4ee5\u8282\u7701\u5185\u5b58\u5e76\u63d0\u9ad8\u6027\u80fd\uff0c\u4f46\u5f88\u591a\u5f00\u53d1\u8005\u4e0d\u7406\u89e3\u5b83\u4eec\u7684\u5de5\u4f5c\u65b9\u5f0f\uff0c\u5bfc\u81f4\u4ee3\u7801\u6548\u7387\u4f4e\u4e0b\u6216\u65e0\u6cd5\u6709\u6548\u5904\u7406\u5927\u578b\u6570\u636e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528\u751f\u6210\u5668 (<code>yield<\/code>) \u6765\u5ef6\u8fdf\u8ba1\u7b97\u548c\u8282\u7701\u5185\u5b58\u3002<\/li>\n\n\n\n<li>\u4e86\u89e3\u8fed\u4ee3\u5668\u534f\u8bae\uff0c\u5b9e\u73b0\u81ea\u5b9a\u4e49\u7684\u8fed\u4ee3\u5668\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>def count_up_to(max):\n    count = 1\n    while count &lt;= max:\n        yield count\n        count += 1\n\nfor number in count_up_to(5):\n    print(number)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">11. <strong>\u8bef\u533a\uff1a\u4e0d\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u76f4\u63a5\u5728\u5168\u5c40\u73af\u5883\u4e2d\u5b89\u88c5 Python \u5305\u4f1a\u5bfc\u81f4\u5305\u7248\u672c\u51b2\u7a81\uff0c\u5c24\u5176\u662f\u5728\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u5171\u4eab\u73af\u5883\u65f6\uff0c\u5bb9\u6613\u5f15\u53d1\u95ee\u9898\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>virtualenv<\/code> \u6216 <code>venv<\/code> \u521b\u5efa\u865a\u62df\u73af\u5883\u6765\u9694\u79bb\u9879\u76ee\u4f9d\u8d56\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>python3 -m venv myenv\nsource myenv\/bin\/activate  # \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">12. <strong>\u8bef\u533a\uff1a\u5728\u5faa\u73af\u4e2d\u9891\u7e41\u8fdb\u884c\u590d\u6742\u64cd\u4f5c<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6709\u65f6\u5019\u5f00\u53d1\u8005\u4f1a\u5728 <code>for<\/code> \u6216 <code>while<\/code> \u5faa\u73af\u4e2d\u8fdb\u884c\u5927\u91cf\u590d\u6742\u7684\u8ba1\u7b97\u6216 I\/O \u64cd\u4f5c\uff0c\u8fd9\u6837\u4e0d\u4ec5\u589e\u52a0\u4e86\u8ba1\u7b97\u65f6\u95f4\uff0c\u8fd8\u53ef\u80fd\u5bfc\u81f4\u6027\u80fd\u74f6\u9888\u3002\u5c24\u5176\u5728\u5927\u6570\u636e\u91cf\u6216\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\uff0c\u8fd9\u79cd\u505a\u6cd5\u7684\u5f71\u54cd\u66f4\u4e3a\u660e\u663e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5c3d\u91cf\u51cf\u5c11\u5faa\u73af\u4e2d\u7684\u91cd\u590d\u8ba1\u7b97\u6216\u5197\u4f59\u64cd\u4f5c\uff0c\u907f\u514d\u6bcf\u6b21\u8fed\u4ee3\u65f6\u90fd\u8fdb\u884c\u4e0d\u5fc5\u8981\u7684\u590d\u6742\u4efb\u52a1\u3002<\/li>\n\n\n\n<li>\u5c06\u590d\u6742\u64cd\u4f5c\u79fb\u51fa\u5faa\u73af\u4f53\uff0c\u6216\u8005\u8003\u8651\u4f7f\u7528\u7f13\u5b58\u6765\u5b58\u50a8\u8ba1\u7b97\u7ed3\u679c\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u53ef\u80fd\u7684\u8bdd\uff0c\u8003\u8651\u4f7f\u7528\u5e76\u884c\u8ba1\u7b97\u6216\u591a\u7ebf\u7a0b\u6765\u4f18\u5316\u6027\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9519\u8bef\u793a\u8303\uff1a\u91cd\u590d\u8ba1\u7b97\nfor i in range(10000):\n    result = complex_calculation(i)  # \u6bcf\u6b21\u90fd\u91cd\u65b0\u8ba1\u7b97\uff0c\u6d6a\u8d39\u65f6\u95f4\n\n# \u6539\u8fdb\uff1a\u5c06\u4e0d\u53d8\u7684\u8ba1\u7b97\u79fb\u51fa\u5faa\u73af\nprecomputed_values = &#91;complex_calculation(i) for i in range(10000)]\nfor i in range(10000):\n    result = precomputed_values&#91;i]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">13. <strong>\u8bef\u533a\uff1a\u4f4e\u6548\u7684\u5b57\u7b26\u4e32\u62fc\u63a5<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5faa\u73af\u4e2d\u4f7f\u7528 <code>+<\/code> \u8fd0\u7b97\u7b26\u6765\u62fc\u63a5\u5b57\u7b26\u4e32\u65f6\uff0c\u6bcf\u6b21\u62fc\u63a5\u90fd\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\uff0c\u589e\u52a0\u4e86\u5185\u5b58\u6d88\u8017\u548c\u6267\u884c\u65f6\u95f4\u3002\u7279\u522b\u662f\u5728\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u65f6\uff0c\u6027\u80fd\u5dee\u5f02\u53ef\u80fd\u975e\u5e38\u660e\u663e\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>join()<\/code> \u65b9\u6cd5\u6765\u62fc\u63a5\u5b57\u7b26\u4e32\uff0c\u5b83\u6bd4\u4f7f\u7528 <code>+<\/code> \u66f4\u9ad8\u6548\uff0c\u7279\u522b\u662f\u5728\u62fc\u63a5\u5927\u91cf\u5b57\u7b26\u4e32\u65f6\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u9700\u8981\u9891\u7e41\u62fc\u63a5\uff0c\u8003\u8651\u4f7f\u7528 <code>StringIO<\/code> \u6216 <code>bytes<\/code> \u7c7b\u578b\u6765\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9519\u8bef\u793a\u8303\uff1a\u4f7f\u7528 + \u62fc\u63a5\u5b57\u7b26\u4e32\nresult = \"\"\nfor i in range(1000):\n    result += str(i)  # \u6bcf\u6b21\u90fd\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\n\n# \u6539\u8fdb\uff1a\u4f7f\u7528 join()\nresult = ''.join(str(i) for i in range(1000))<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">14. <strong>\u8bef\u533a\uff1a\u5fd8\u8bb0\u5173\u95ed\u8d44\u6e90\uff08\u6587\u4ef6\u3001\u7f51\u7edc\u8fde\u63a5\u7b49\uff09<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728 Python \u4e2d\uff0c\u6253\u5f00\u6587\u4ef6\u3001\u6570\u636e\u5e93\u8fde\u63a5\u3001\u7f51\u7edc\u5957\u63a5\u5b57\u7b49\u8d44\u6e90\u540e\uff0c\u5982\u679c\u5fd8\u8bb0\u5173\u95ed\u5b83\u4eec\uff0c\u4f1a\u5bfc\u81f4\u8d44\u6e90\u6cc4\u6f0f\u3001\u5185\u5b58\u6ea2\u51fa\u7b49\u95ee\u9898\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>with<\/code> \u8bed\u53e5\u6765\u81ea\u52a8\u7ba1\u7406\u8d44\u6e90\uff0c\u786e\u4fdd\u5b83\u4eec\u5728\u4f7f\u7528\u5b8c\u540e\u5f97\u5230\u6b63\u786e\u5173\u95ed\u3002\u5bf9\u4e8e\u6587\u4ef6\u3001\u7f51\u7edc\u8fde\u63a5\u7b49\uff0c<code>with<\/code> \u4f1a\u81ea\u52a8\u8c03\u7528 <code>__exit__<\/code> \u65b9\u6cd5\uff0c\u91ca\u653e\u8d44\u6e90\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9519\u8bef\u793a\u8303\uff1a\u624b\u52a8\u6253\u5f00\u548c\u5173\u95ed\u6587\u4ef6\uff0c\u53ef\u80fd\u5fd8\u8bb0\u5173\u95ed\nfile = open('data.txt', 'r')\ndata = file.read()\n# \u5fd8\u8bb0 file.close()\n\n# \u6539\u8fdb\uff1a\u4f7f\u7528 with \u8bed\u53e5\nwith open('data.txt', 'r') as file:\n    data = file.read()  # \u81ea\u52a8\u5173\u95ed\u6587\u4ef6<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">15. <strong>\u8bef\u533a\uff1a\u9519\u8bef\u5730\u4f7f\u7528 <code>filter()<\/code> \u548c <code>map()<\/code><\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>filter()<\/code> \u548c <code>map()<\/code> \u51fd\u6570\u8fd4\u56de\u7684\u662f\u8fed\u4ee3\u5668\u5bf9\u8c61\uff0c\u5728\u4e00\u4e9b\u60c5\u51b5\u4e0b\uff0c\u5f00\u53d1\u8005\u53ef\u80fd\u4f1a\u8bef\u7528\u5b83\u4eec\uff0c\u5bfc\u81f4\u7ed3\u679c\u4e0d\u5982\u9884\u671f\uff0c\u6216\u8005\u5fd8\u8bb0\u5c06\u5176\u8f6c\u6362\u4e3a\u5217\u8868\u3001\u5143\u7ec4\u7b49\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>list()<\/code> \u6216\u5176\u4ed6\u7c7b\u578b\u8f6c\u6362\u51fd\u6570\u6765\u663e\u5f0f\u5730\u8f6c\u6362 <code>filter()<\/code> \u548c <code>map()<\/code> \u7684\u7ed3\u679c\u3002<\/li>\n\n\n\n<li>\u5728\u4e0d\u9700\u8981\u61d2\u52a0\u8f7d\u7684\u60c5\u51b5\u4e0b\uff0c\u8003\u8651\u4f7f\u7528\u5217\u8868\u63a8\u5bfc\u5f0f\uff08\u5217\u8868\u89e3\u6790\uff09\u4ee3\u66ff <code>filter()<\/code> \u548c <code>map()<\/code>\uff0c\u5b83\u901a\u5e38\u66f4\u76f4\u89c2\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9519\u8bef\u793a\u8303\uff1a\u4f7f\u7528 filter\/map \u540e\u6ca1\u6709\u8f6c\u6362\u4e3a\u5217\u8868\nresult = filter(lambda x: x &gt; 5, range(10))\n# result \u662f\u4e00\u4e2a\u8fed\u4ee3\u5668\uff0c\u76f4\u63a5\u6253\u5370\u4f1a\u663e\u793a\u4e00\u4e2a\u5bf9\u8c61\u800c\u975e\u7ed3\u679c\n\n# \u6539\u8fdb\uff1a\u663e\u5f0f\u8f6c\u6362\u4e3a\u5217\u8868\nresult = list(filter(lambda x: x &gt; 5, range(10)))\nprint(result)  # \u8f93\u51fa &#91;6, 7, 8, 9]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">16. <strong>\u8bef\u533a\uff1a\u5728\u5f02\u5e38\u5904\u7406\u4e2d\u4f7f\u7528\u8fc7\u4e8e\u5bbd\u6cdb\u7684 <code>except<\/code><\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6355\u83b7\u5f02\u5e38\u65f6\uff0c\u4f7f\u7528\u4e00\u4e2a\u8fc7\u4e8e\u5bbd\u6cdb\u7684 <code>except<\/code>\uff08\u5982 <code>except:<\/code> \u6216 <code>except Exception:<\/code>\uff09\u53ef\u80fd\u4f1a\u6355\u83b7\u6240\u6709\u5f02\u5e38\uff0c\u751a\u81f3\u662f\u4e00\u4e9b\u4e0d\u5e94\u88ab\u6355\u83b7\u7684\u7cfb\u7edf\u5f02\u5e38\uff0c\u5bfc\u81f4\u95ee\u9898\u4e0d\u6613\u8ffd\u8e2a\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6355\u83b7\u7279\u5b9a\u7684\u5f02\u5e38\uff0c\u5e76\u5bf9\u4e0d\u540c\u7c7b\u578b\u7684\u5f02\u5e38\u505a\u51fa\u4e0d\u540c\u7684\u5904\u7406\u3002<\/li>\n\n\n\n<li>\u907f\u514d\u4f7f\u7528\u8fc7\u4e8e\u5bbd\u6cdb\u7684\u5f02\u5e38\u6355\u83b7\uff0c\u6700\u597d\u9488\u5bf9\u5177\u4f53\u7684\u9519\u8bef\u7c7b\u578b\u8fdb\u884c\u5904\u7406\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9519\u8bef\u793a\u8303\uff1a\u6355\u83b7\u6240\u6709\u5f02\u5e38\ntry:\n    result = 10 \/ 0\nexcept:\n    print(\"\u53d1\u751f\u9519\u8bef\")\n\n# \u6539\u8fdb\uff1a\u6355\u83b7\u7279\u5b9a\u5f02\u5e38\ntry:\n    result = 10 \/ 0\nexcept ZeroDivisionError:\n    print(\"\u4e0d\u80fd\u9664\u4ee5\u96f6\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">17. <strong>\u8bef\u533a\uff1a\u5ffd\u89c6 Python \u7684\u5185\u5b58\u7ba1\u7406<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u4f7f\u7528\u5f15\u7528\u8ba1\u6570\u548c\u5783\u573e\u56de\u6536\u673a\u5236\u6765\u7ba1\u7406\u5185\u5b58\uff0c\u5f00\u53d1\u8005\u6709\u65f6\u4f1a\u5ffd\u89c6\u8fd9\u90e8\u5206\uff0c\u5bfc\u81f4\u5185\u5b58\u6cc4\u6f0f\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u5927\u578b\u5bf9\u8c61\u6216\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\u65f6\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>gc<\/code> \u6a21\u5757\u4e86\u89e3\u548c\u7ba1\u7406 Python \u7684\u5783\u573e\u56de\u6536\u673a\u5236\u3002<\/li>\n\n\n\n<li>\u5b9a\u671f\u68c0\u67e5\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u5927\u578b\u6570\u636e\u6216\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u7a0b\u5e8f\u65f6\u3002<\/li>\n\n\n\n<li>\u4e86\u89e3\u5e76\u907f\u514d\u5faa\u73af\u5f15\u7528\uff0c\u4ee5\u786e\u4fdd\u5783\u573e\u56de\u6536\u80fd\u591f\u987a\u5229\u56de\u6536\u5bf9\u8c61\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>import gc\n\ngc.collect()  # \u5f3a\u5236\u8fdb\u884c\u5783\u573e\u56de\u6536<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">18. <strong>\u8bef\u533a\uff1a\u4f4e\u6548\u7684\u5f02\u5e38\u5904\u7406<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6709\u4e9b\u5f00\u53d1\u8005\u5c06\u5f02\u5e38\u4f5c\u4e3a\u63a7\u5236\u6d41\u7684\u4e00\u90e8\u5206\uff0c\u8fc7\u5ea6\u4f9d\u8d56\u5f02\u5e38\u5904\u7406\u6765\u7ba1\u7406\u6b63\u5e38\u7684\u6d41\u7a0b\u63a7\u5236\u3002\u8fd9\u4e0d\u4ec5\u4f7f\u4ee3\u7801\u53d8\u5f97\u4e0d\u6e05\u6670\uff0c\u8fd8\u53ef\u80fd\u964d\u4f4e\u7a0b\u5e8f\u7684\u6027\u80fd\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f02\u5e38\u5e94\u5f53\u7528\u4e8e\u6355\u83b7\u771f\u6b63\u7684\u5f02\u5e38\u60c5\u51b5\uff0c\u800c\u4e0d\u662f\u5e38\u89c4\u7684\u7a0b\u5e8f\u6d41\u7a0b\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u9884\u671f\u7684\u9519\u8bef\uff0c\u53ef\u4ee5\u901a\u8fc7\u6761\u4ef6\u5224\u65ad\uff08\u5982 <code>if<\/code> \u8bed\u53e5\uff09\u6765\u907f\u514d\u5f15\u53d1\u5f02\u5e38\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9519\u8bef\u793a\u8303\uff1a\u7528\u5f02\u5e38\u5904\u7406\u63a7\u5236\u6d41\ntry:\n    result = my_dict&#91;key]\nexcept KeyError:\n    result = None\n\n# \u6539\u8fdb\uff1a\u5148\u68c0\u67e5\u952e\u662f\u5426\u5b58\u5728\nif key in my_dict:\n    result = my_dict&#91;key]\nelse:\n    result = None<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">19. <strong>\u8bef\u533a\uff1a\u4e0d\u4f7f\u7528\u7c7b\u578b\u63d0\u793a<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5c3d\u7ba1 Python \u662f\u52a8\u6001\u7c7b\u578b\u8bed\u8a00\uff0c\u4f46\u6ca1\u6709\u7c7b\u578b\u63d0\u793a\u7684\u60c5\u51b5\u4e0b\uff0c\u5f00\u53d1\u8005\u5f88\u5bb9\u6613\u9047\u5230\u7c7b\u578b\u9519\u8bef\uff0c\u5c24\u5176\u5728\u5927\u578b\u9879\u76ee\u4e2d\uff0c\u7f3a\u4e4f\u660e\u786e\u7684\u7c7b\u578b\u58f0\u660e\u4f1a\u589e\u52a0\u4ee3\u7801\u7684\u7406\u89e3\u548c\u7ef4\u62a4\u6210\u672c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 Python \u7684\u7c7b\u578b\u63d0\u793a\uff08PEP 484\uff09\u4e3a\u51fd\u6570\u548c\u53d8\u91cf\u6dfb\u52a0\u7c7b\u578b\u6ce8\u89e3\uff0c\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\uff0c\u5e76\u51cf\u5c11\u7c7b\u578b\u76f8\u5173\u7684\u9519\u8bef\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code># \u9519\u8bef\u793a\u8303\uff1a\u6ca1\u6709\u7c7b\u578b\u63d0\u793a\ndef add(a, b):\n    return a + b\n\n# \u6539\u8fdb\uff1a\u4f7f\u7528\u7c7b\u578b\u63d0\u793a\ndef add(a: int, b: int) -&gt; int:\n    return a + b<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u907f\u514d\u8fd9\u4e9b\u5e38\u89c1\u7684 Python \u5f00\u53d1\u8bef\u533a\uff0c\u80fd\u591f\u5927\u5927\u63d0\u5347\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u5173\u952e\u5728\u4e8e\u7406\u89e3 Python \u7684\u8bbe\u8ba1\u54f2\u5b66\u3001\u8bed\u8a00\u7279\u6027\u548c\u6700\u4f73\u5b9e\u8df5\uff0c\u5e76\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u4fdd\u6301\u5bf9\u7ec6\u8282\u7684\u5173\u6ce8\u3002\u5728\u5e94\u7528 Python \u65f6\uff0c\u5b66\u4f1a\u5982\u4f55\u4f18\u5316\u6027\u80fd\u3001\u7ba1\u7406\u8d44\u6e90\u3001\u5904\u7406\u5f02\u5e38\uff0c\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u66f4\u53ef\u9760\u3001\u66f4\u9ad8\u6548\u7684\u5e94\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5e94\u7528 Python \u65f6\uff0c\u5f00\u53d1\u8005\u5e38\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8bef\u533a\uff0c\u7406\u89e3\u5e76\u907f\u514d\u8fd9\u4e9b\u8bef\u533a\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u9ad8\u6548\u5730\u7f16\u7a0b\u5e76\u51cf\u5c11\u8c03\u8bd5\u548c\u9519\u8bef\u7684 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[],"class_list":["post-1491","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1491","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=1491"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1491\/revisions"}],"predecessor-version":[{"id":1492,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1491\/revisions\/1492"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=1491"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=1491"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=1491"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}