{"id":424,"date":"2021-12-20T22:06:39","date_gmt":"2021-12-20T14:06:39","guid":{"rendered":"http:\/\/139.9.1.231\/?p=424"},"modified":"2021-12-20T22:06:40","modified_gmt":"2021-12-20T14:06:40","slug":"python","status":"publish","type":"post","link":"http:\/\/139.9.1.231\/index.php\/2021\/12\/20\/python\/","title":{"rendered":"Python 3 \u65b0\u7279\u6027\uff1a\u7c7b\u578b\u6ce8\u89e3"},"content":{"rendered":"\n<p>\u6458\u81ea\uff1ahttps:\/\/www.cnblogs.com\/xzkzzz\/p\/11378842.html<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img src=\"https:\/\/cdn.pixabay.com\/photo\/2021\/05\/11\/06\/22\/night-sky-6245049_1280.jpg\" alt=\"\"\/><figcaption>https:\/\/pixabay.com\/<\/figcaption><\/figure>\n\n\n\n<p>\u5728 Python \u4e2d\u5b9a\u4e49\u51fd\u6570\u975e\u5e38\u7b80\u5355\uff0c\u50cf\u8fd9\u6837\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def say(name):\n    return f'Hello {name}!'\n<\/pre>\n\n\n\n<p>\u4f46\u662f\uff0c\u6709\u65f6\u5019\u4e5f\u4f1a\u770b\u5230\u8fd9\u6837\u7684\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def say_hi(name: str) -&gt; str:\n    return f'Hello {name}!'\n<\/pre>\n\n\n\n<p>\u51fd\u6570\u5b9a\u4e49\u4f3c\u4e4e\u53d8\u5f97\u590d\u6742\u4e9b\u4e86\uff1a\u591a\u51fa\u6765\u8fd9\u4e9b&nbsp;<code>str<\/code>&nbsp;\u3001&nbsp;<code>-&gt;<\/code>&nbsp;\u90fd\u662f\u4ec0\u4e48\u610f\u601d\uff1f\u6709\u4ec0\u4e48\u4f5c\u7528\uff1f<\/p>\n\n\n\n<p>\u672c\u6587\u5c06\u7531\u6d45\u5165\u6df1\uff0c\u597d\u597d\u804a\u804a Python 3.5 \u4e4b\u540e\u7684<strong>\u7c7b\u578b\u6ce8\u89e3<\/strong>\u3002\u7406\u89e3\u5b83\u5c06\u975e\u5e38\u6709\u76ca\u4e8e\u4f18\u5316\u4f60\u7684\u4ee3\u7801\u3002<\/p>\n\n\n\n<h2 id=\"_1\">\u53d8\u91cf\u6ce8\u89e3<\/h2>\n\n\n\n<p>Python \u662f<strong>\u52a8\u6001\u8bed\u8a00<\/strong>\uff0c\u5176\u663e\u8457\u7279\u70b9\u662f\u5728\u58f0\u660e\u53d8\u91cf\u65f6\uff0c\u4f60\u4e0d\u9700\u8981<em>\u663e\u5f0f<\/em>\u58f0\u660e\u5b83\u7684\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u8fd9\u4e2a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">age = 20\nprint('The age is: ', age + 1)\n# Output:\n# The age is:  21\n<\/pre>\n\n\n\n<p>\u4f60\u770b\uff0c\u867d\u7136\u4ee3\u7801\u91cc\u6ca1\u6709\u660e\u786e\u6307\u5b9a&nbsp;<code>age<\/code>&nbsp;\u7684\u7c7b\u578b\uff0c\u4f46\u662f\u7a0b\u5e8f\u8fd0\u884c\u65f6<em>\u9690\u5f0f\u63a8\u65ad<\/em>\u51fa\u5b83\u662f&nbsp;<code>int<\/code>&nbsp;\u7c7b\u578b\uff0c\u56e0\u6b64\u53ef\u4ee5\u987a\u5229\u6267\u884c&nbsp;<code>age + 1<\/code>&nbsp;\u7684\u52a8\u4f5c\u3002<\/p>\n\n\n\n<p>\u9664\u6b64\u4e4b\u5916\uff0c\u5df2\u7ecf\u786e\u5b9a\u7c7b\u578b\u7684\u53d8\u91cf\uff0c\u53ef\u4ee5\u968f\u65f6\u66f4\u6539\u5176\u7c7b\u578b\uff0c\u6bd4\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">age = 20\nprint(type(age))\n# Output: &lt;class 'int'&gt;\n\nage = '20'\nprint(type(age))\n# Output: &lt;class 'str'&gt;\n<\/pre>\n\n\n\n<p>Python \u8fd9\u79cd\u52a8\u6001\u7279\u6027\u7684\u597d\u5904\u662f\u5b83\u975e\u5e38\u7684\u81ea\u7531\uff0c\u5927\u90e8\u5206\u65f6\u5019\u4f60\u4e0d\u7528\u7ea0\u7ed3\u7c7b\u578b\u58f0\u660e\u3001\u7c7b\u578b\u8f6c\u5316\u7b49\u9ebb\u70e6\u4e8b\uff0c\u53ef\u4ee5\u7528\u5f88\u5c11\u7684\u4ee3\u7801\u5b8c\u6210\u5404\u79cd\u9a9a\u64cd\u4f5c\u3002\u4f46\u662f\u7f3a\u70b9\u4e5f\u5728\u8fd9\u91cc\uff1a\u5982\u679c\u4f60\u4ee3\u7801\u67d0\u4e9b\u53d8\u91cf\u7684\u7c7b\u578b\u6709\u9519\uff0c\u7f16\u8f91\u5668\u3001IDE\u7b49\u5de5\u5177\u65e0\u6cd5\u5728\u65e9\u671f\u66ff\u4f60\u7ea0\u9519\uff0c\u53ea\u80fd\u5728\u7a0b\u5e8f\u8fd0\u884c\u9636\u6bb5\u624d\u80fd\u591f\u66b4\u9732\u95ee\u9898\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">age = 20\n\n# ...\n# \u8fd9\u91cc\u8fdb\u884c\u4e86\u4e00\u5927\u4e32\u7684\u5176\u4ed6\u6307\u4ee4\n# \u7136\u540e\u4f60\u5fd8\u8bb0\u4e86 age \u5e94\u8be5\u662f int\n# \u9519\u8bef\u5730\u5c06\u5176\u8d4b\u503c\u4e3a\u5b57\u7b26\u4e32\n\nage = '20'\n\nprint('The age is: ', age + 1)\n# Output: TypeError: can only concatenate str (not \"int\") to str\n<\/pre>\n\n\n\n<p>\u5728\u9879\u76ee\u4ee3\u7801\u9010\u6e10\u81a8\u80c0\u4e4b\u540e\uff0c\u4e0a\u9762\u8fd9\u79cd\u770b\u4f3c\u5f31\u667a\u7684\u60c5\u51b5\u53ef\u80fd\u4f1a\u7ecf\u5e38\u53d1\u751f\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0cPython 3.5 \u4e4b\u540e\u5f15\u5165\u4e86<strong>\u7c7b\u578b\u6ce8\u89e3<\/strong>\uff0c\u5176\u4f5c\u7528\u5c31\u662f\u8ba9\u4f60\u53ef\u4ee5\u660e\u786e\u7684\u58f0\u660e\u53d8\u91cf\u7684\u7c7b\u578b\uff0c\u4f7f\u4ee3\u7801\u4e0d\u518d\u90a3\u4e48\u7684\u81ea\u7531\uff08\u653e\u98de\u81ea\u6211\uff09\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u7c7b\u578b\u6ce8\u89e3\u8fd8\u5728\u5feb\u901f\u53d1\u5c55\u4e2d\uff0c\u56e0\u6b64\u5c3d\u91cf\u7528\u8f83\u65b0\u7684 Python \u7248\u672c\u53bb\u5c1d\u8bd5\u5b83\u3002<\/p><\/blockquote>\n\n\n\n<p>\u6bd4\u5982\u4e0a\u9762\u7684\u4ee3\u7801\uff0c\u5c31\u53ef\u4ee5\u7528\u7c7b\u578b\u6ce8\u89e3\u6539\u5199\u4e86\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">age: int = 20\n<\/pre>\n\n\n\n<p>\u770b\u4f3c\u591a\u6b64\u4e00\u4e3e\uff0c\u4f46\u662f\u7f16\u8f91\u5668\u53ef\u4ee5\u51ed\u501f\u6b64\uff0c\u627e\u51fa\u4f60\u90a3\u4e9b\u9519\u8bef\u7684\u9a9a\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u7b14\u8005\u7528\u7684&nbsp;<strong>VS Code<\/strong>\uff0c\u5b89\u88c5\u597d\u7c7b\u578b\u6ce8\u89e3\u63d2\u4ef6&nbsp;<strong>Pylance<\/strong>&nbsp;\u540e\uff0c\u5982\u679c\u5199\u51fa\u4e0b\u9762\u7684\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">age: int = 20\nage = '20'\n<\/pre>\n\n\n\n<p>\u90a3\u4e48\u7f16\u8f91\u5668\u4f1a\u7528<strong>\u9192\u76ee<\/strong>\u7684\u65b9\u5f0f\u544a\u8bc9\u4f60\uff1a\u5b59\u5b50\uff0c\u4f60\u8fd9\u91cc\u7684\u7c7b\u578b\u5199\u9519\u4e86\uff01\uff08\u89c1\u4e0b\u56fe\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"https:\/\/blog.dusaiphoto.com\/typing-1.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>Pylance \u9ed8\u8ba4\u5173\u95ed\u4e86\u7c7b\u578b\u68c0\u67e5\uff0c\u4f60\u5f97\u5728\u8bbe\u7f6e\u4e2d\u624b\u52a8\u6253\u5f00\u3002\u5176\u4ed6\u7684\u7f16\u8f91\u5668\/IDE\uff08\u6bd4\u5982 Pycharm\uff09\u4e5f\u90fd\u63d0\u4f9b\u4e86\u7c7b\u4f3c\u7684\u7c7b\u578b\u68c0\u67e5\uff0c\u653e\u5fc3\u7528\u5427\u3002<\/p><\/blockquote>\n\n\n\n<p>\u5f88\u7b80\u5355\uff0c\u4f46\u5374\u5e26\u6765\u4e86<strong>\u5de8\u5927\u7684\u597d\u5904<\/strong>\uff1a<\/p>\n\n\n\n<ul><li>\u7f16\u8f91\u5668\u53ef\u4ee5\u66ff\u4f60\u63ea\u51fa\u4ee3\u7801\u4e2d\u5173\u4e8e\u7c7b\u578b\u7684\u9519\u8bef\uff0c\u907f\u514d\u4e86\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u5404\u79cd\u5947\u5947\u602a\u602a\u7684 Bug \u3002<\/li><li>\u5728\u4f60\u7f16\u5199\u4ee3\u7801\u65f6\uff0c\u7f16\u8f91\u5668\u53ef\u4ee5\u63d0\u793a\u4f60\u5bf9\u8c61\u7684\u7c7b\u578b\uff0c\u514d\u5f97\u4f60\u6216\u8005\u56e2\u961f\u6210\u5458\u5fd8\u8bb0\u4e86\u3002\uff08\u7a0b\u5e8f\u5458\u901a\u5e38\u8bb0\u6027\u4e0d\u597d\uff09\u3002<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image is-style-default\"><img src=\"https:\/\/blog.dusaiphoto.com\/typing-2.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>\u6ce8\u610f<\/strong>\uff0c\u7c7b\u578b\u6ce8\u89e3<strong>\u4ec5\u4ec5<\/strong>\u662f\u63d0\u4f9b\u7ed9\u7f16\u8f91\u5668\u8fdb\u884c\u7c7b\u578b\u68c0\u67e5\u7684\u673a\u4f1a\uff0c\u4e5f\u5c31\u662f\u8d77\u63d0\u793a\u7684\u4f5c\u7528\uff0c\u5bf9 Python \u7a0b\u5e8f\u7684\u8fd0\u884c\u4e0d\u4f1a\u4ea7\u751f\u4efb\u4f55\u5f71\u54cd\u3002\u4e5f\u5c31\u662f\u8bf4\uff0cPython \u8ddf\u4ee5\u524d\u4e00\u6837\u81ea\u7531\uff0c\u5373\u4f7f\u4f60\u8fdb\u884c\u4e86\u9519\u8bef\u7684\u7c7b\u578b\u8d4b\u503c\uff0c\u53ea\u8981\u4e0d\u76f4\u63a5\u5f15\u53d1\u9519\u8bef\uff0c\u7a0b\u5e8f\u4f9d\u65e7\u53ef\u4ee5\u8fd0\u884c\u3002<\/p>\n\n\n\n<p>\u6700\u540e\uff0cPython \u4e2d\u51e0\u79cd\u57fa\u672c\u7684\u53d8\u91cf\u7c7b\u578b\u90fd\u5f97\u5230\u4e86\u652f\u6301\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">a: int = 3\nb: float = 3.14\nc: str = 'abc'\nd: bool = False\n<\/pre>\n\n\n\n<p>\u5f88\u7b80\u5355\u5427\u3002\u8ba9\u6211\u4eec\u7ee7\u7eed\u3002<\/p>\n\n\n\n<h2 id=\"_2\">\u51fd\u6570\u6ce8\u89e3<\/h2>\n\n\n\n<p>\u6587\u7ae0\u5f00\u5934\u63d0\u5230\u7684\u90a3\u4e2a\u4f8b\u5b50\uff0c\u5c31\u662f\u7b80\u5355\u7684\u51fd\u6570\u7c7b\u578b\u6ce8\u89e3\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def say_hi(name: str) -&gt; str:\n    return f'Hello {name}!'\n<\/pre>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u5f88\u6e05\u695a\u7684\u77e5\u9053\uff0c\u8fd9\u4e2a\u51fd\u6570<em>\u5e94\u8be5<\/em>\u63a5\u6536\u4e00\u4e2a\u5b57\u7b26\u4e32\u53c2\u6570&nbsp;<code>name<\/code>&nbsp;\uff0c\u5e76\u4e14\u8fd4\u56de\u503c<em>\u5e94\u8be5<\/em>\u4e5f\u662f\u5b57\u7b26\u4e32\u3002<\/p>\n\n\n\n<p>\u5e26\u9ed8\u8ba4\u503c\u7684\u51fd\u6570\u50cf\u8fd9\u6837\u4e66\u5199\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def add(first: int = 10, second: float = 5.5) -&gt; float:\n    return first + second\n<\/pre>\n\n\n\n<p>\u5982\u679c\u51fd\u6570\u6ca1\u6709\u8fd4\u56de\u503c\uff0c\u90a3\u4e48\u4e0b\u9762\u4e24\u79cd\u5199\u6cd5\u90fd\u53ef\u4ee5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def foo():\n    pass\n\ndef bar() -&gt; None:\n    pass\n<\/pre>\n\n\n\n<p>\u81ea\u5b9a\u4e49\u7684\u5bf9\u8c61\u4e5f\u6ca1\u95ee\u9898\uff0c\u50cf\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class Person:\n    def __init__(self, name: str):\n        self.name = name\n\n\ndef hello(p: Person) -&gt; str:\n    return f'Hello, {p.name}'\n<\/pre>\n\n\n\n<p>\u5982\u679c\u8981\u907f\u514d\u5faa\u73af\u5bfc\u5165\u6216\u8005\u6ce8\u89e3\u65e9\u4e8e\u5bf9\u8c61\u5b9a\u4e49\u7684\u60c5\u51b5\uff0c\u53ef\u4ee5\u7528\u5b57\u7b26\u4e32\u4ee3\u66ff\u7c7b\u578b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def hello(p: 'Person') -&gt; str:\n    return f'Hello, {p.name}'\n\n\nclass Person:\n    def __init__(self, name: str):\n        self.name = name\n<\/pre>\n\n\n\n<p>\u6548\u679c\u662f\u76f8\u540c\u7684\u3002<\/p>\n\n\n\n<p>\u76f8\u6bd4\u53d8\u91cf\u7c7b\u578b\u6ce8\u89e3\uff0c\u51fd\u6570\u91cc\u7684\u7c7b\u578b\u6ce8\u89e3\u66f4\u52a0\u6709\u7528\uff0c\u5e76\u4e14\u53ef\u80fd\u662f\u4f60\u6700\u9891\u7e41\u7528\u5230\u6ce8\u89e3\u7684\u5730\u65b9\u4e86\u3002<\/p>\n\n\n\n<h2 id=\"_3\">\u5bb9\u5668\u7c7b\u578b<\/h2>\n\n\n\n<p>\u5217\u8868\u3001\u5b57\u5178\u3001\u5143\u7ec4\u7b49\u5305\u542b\u5143\u7d20\u7684\u590d\u5408\u7c7b\u578b\uff0c\u7528\u7b80\u5355\u7684 list\uff0cdict\uff0ctuple \u4e0d\u80fd\u591f\u660e\u786e\u8bf4\u660e\u5185\u90e8\u5143\u7d20\u7684\u5177\u4f53\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\u8981\u7528\u5230&nbsp;<code>typing<\/code>&nbsp;\u6a21\u5757\u63d0\u4f9b\u7684<strong>\u590d\u5408\u6ce8\u89e3<\/strong>\u529f\u80fd\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import List, Dict, Tuple\n\n# \u53c2\u65701: \u5143\u7d20\u4e3a int \u7684\u5217\u8868\n# \u53c2\u65702: \u952e\u4e3a\u5b57\u7b26\u4e32\uff0c\u503c\u4e3a int \u7684\u5b57\u5178\n# \u8fd4\u56de\u503c: \u5305\u542b\u4e24\u4e2a\u5143\u7d20\u7684\u5143\u7ec4\ndef mix(scores: List[int], ages: Dict[str, int]) -&gt; Tuple[int, int]:\n    return (0, 0)\n<\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u7528\u7684\u662f Python 3.9+ \u7248\u672c\uff0c\u751a\u81f3\u8fde&nbsp;<code>typing<\/code>&nbsp;\u6a21\u5757\u90fd\u4e0d\u9700\u8981\u4e86\uff0c\u5185\u7f6e\u7684\u5bb9\u5668\u7c7b\u578b\u5c31\u652f\u6301\u4e86\u590d\u5408\u6ce8\u89e3\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def mix(scores: list[int], ages: dict[str, int]) -&gt; tuple[int, int]:\n    return (0, 0)\n<\/pre>\n\n\n\n<p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4e0d\u9700\u8981\u4e25\u683c\u533a\u5206\u53c2\u6570\u5230\u5e95\u662f\u5217\u8868\u8fd8\u662f\u5143\u7ec4\uff08\u8fd9\u79cd\u60c5\u51b5\u8fd8\u86ee\u591a\u7684\uff09\u3002\u8fd9\u65f6\u5019\u5c31\u53ef\u4ee5\u5c06\u5b83\u4eec\u7684\u7279\u5f81\u62bd\u8c61\u4e3a\u66f4\u6cdb\u5316\u7684\u7c7b\u578b\uff08\u6cdb\u578b\uff09\uff0c\u6bd4\u5982 Sequence\uff08\u5e8f\u5217\uff09\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Python 3.8 \u4e4b\u524d\u7684\u7248\u672c\nfrom typing import Sequence as Seq1\n\ndef foo(seq: Seq1[str]):\n    for item in seq:\n        print(item)\n\n\n# Python 3.9+ \u4e5f\u53ef\u4ee5\u8fd9\u4e48\u5199\nfrom collections.abc import Sequence as Seq2\n\ndef bar(seq: Seq2[str]):\n    for item in seq:\n        print(item)\n<\/pre>\n\n\n\n<p>\u4f8b\u5b50\u4e2d\u51fd\u6570\u7684\u53c2\u6570\u4e0d\u5bf9\u5bb9\u5668\u7684\u7c7b\u578b\u505a\u5177\u4f53\u8981\u6c42\uff0c\u53ea\u8981\u5b83\u662f\u4e2a\u5e8f\u5217\uff08\u6bd4\u5982\u5217\u8868\u548c\u5143\u7ec4\uff09\u5c31\u53ef\u4ee5\u3002<\/p>\n\n\n\n<h2 id=\"_4\">\u7c7b\u578b\u522b\u540d<\/h2>\n\n\n\n<p>\u6709\u65f6\u5019\u5bf9\u8c61\u7684\u7c7b\u578b\u53ef\u80fd\u4f1a\u975e\u5e38\u590d\u6742\uff0c\u6216\u8005\u4f60\u5e0c\u671b\u7ed9\u7c7b\u578b\u8d4b\u4e88\u4e00\u4e2a\u6709\u610f\u4e49\u7684\u540d\u79f0\uff0c\u90a3\u4e48\u4f60\u53ef\u4ee5\u8fd9\u6837\u5b9a\u4e49\u7c7b\u578b\u7684\u522b\u540d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Tuple\n\n# \u7c7b\u578b\u522b\u540d\nVector2D = Tuple[int, int]\n\ndef foo(vector: Vector2D):\n    print(vector)\n\nfoo(vector=(1, 2))\n# Output: (1, 2)\n<\/pre>\n\n\n\n<p><code>Vector2D<\/code>&nbsp;\u8fd9\u4e2a\u540d\u79f0\u6e05\u6670\u7684\u8868\u8fbe\u4e86\u8fd9\u4e2a\u5bf9\u8c61\u662f\u4e00\u4e2a\u4e8c\u7ef4\u7684\u5411\u91cf\u3002<\/p>\n\n\n\n<p>\u4e0e\u7c7b\u578b\u522b\u540d\u6709\u70b9\u7c7b\u4f3c\u7684\uff0c\u662f\u7528&nbsp;<code>NewType<\/code>&nbsp;\u521b\u5efa\u81ea\u5b9a\u4e49\u7c7b\u578b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import NewType\nfrom typing import Tuple\n\n# \u521b\u5efa\u65b0\u7c7b\u578b\nVector3D = NewType('Vector3D', Tuple[int, int, int])\n\ndef bar(vector: Vector3D):\n    print(vector)\n<\/pre>\n\n\n\n<p>\u4e4d\u4e00\u773c\u770b\u8d77\u6765\u4e0e\u524d\u9762\u7684\u7c7b\u578b\u522b\u540d\u529f\u80fd\u5dee\u4e0d\u591a\uff0c\u4f46\u4e0d\u540c\u7684\u662f&nbsp;<code>NewType<\/code>&nbsp;\u521b\u5efa\u4e86\u539f\u59cb\u7c7b\u578b\u7684\u201c\u5b50\u7c7b\u201d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u7c7b\u578b\u68c0\u67e5\u6210\u529f\n# \u7c7b\u578b\u522b\u540d\u548c\u539f\u59cb\u7c7b\u578b\u662f\u7b49\u4ef7\u7684\nfoo(vector=(1, 2))\n\n# \u7c7b\u578b\u68c0\u67e5\u5931\u8d25\n# NewType\u521b\u5efa\u7684\u662f\u539f\u59cb\u7c7b\u578b\u7684\u201c\u5b50\u7c7b\u201d\nbar(vector=(1, 2, 3))\n\n# \u7c7b\u578b\u68c0\u67e5\u6210\u529f\n# \u4f20\u5165\u53c2\u6570\u5fc5\u987b\u662f Vector3D \u7684\u201c\u5b9e\u4f8b\u201d\nv_3d = Vector3D((4, 5, 6))\nbar(vector=v_3d)\n<\/pre>\n\n\n\n<p>\u5177\u4f53\u7528\u54ea\u79cd\uff0c\u5f97\u6839\u636e\u60c5\u51b5\u800c\u5b9a\u3002<\/p>\n\n\n\n<h2 id=\"_5\">\u66f4\u591a\u7c7b\u578b<\/h2>\n\n\n\n<h3 id=\"noreturn\">NoReturn<\/h3>\n\n\n\n<p>\u5982\u679c\u51fd\u6570\u6ca1\u6709\u8fd4\u56de\u503c\uff0c\u90a3\u4e48\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import NoReturn\n\ndef hello() -&gt; NoReturn:\n    raise RuntimeError('oh no')\n<\/pre>\n\n\n\n<p>\u6ce8\u610f\u4e0b\u9762\u8fd9\u6837\u5199\u662f\u9519\u8bef\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def hello() -&gt; NoReturn:\n    pass\n<\/pre>\n\n\n\n<p>\u56e0\u4e3a Python \u7684\u51fd\u6570\u8fd0\u884c\u7ed3\u675f\u65f6\u9690\u5f0f\u8fd4\u56de&nbsp;<code>None<\/code>&nbsp;\uff0c\u8fd9\u548c\u771f\u6b63\u7684\u65e0\u8fd4\u56de\u503c\u662f\u6709\u533a\u522b\u7684\u3002<\/p>\n\n\n\n<h3 id=\"optional\">Optional<\/h3>\n\n\n\n<p>\u731c\u731c\u4e0b\u9762\u7684\u7c7b\u578b\u6ce8\u89e3\u9519\u5728\u54ea\u91cc\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def foo(a: int = 0) -&gt; str:\n    if a == 1:\n        return 'Yeah'\n<\/pre>\n\n\n\n<p>\u7b54\u6848\uff1a\u51fd\u6570\u65e2\u6709\u53ef\u80fd\u8fd4\u56de&nbsp;<code>None<\/code>&nbsp;\uff0c\u4e5f\u6709\u53ef\u80fd\u8fd4\u56de&nbsp;<code>str<\/code>&nbsp;\u3002\u5355\u51ed\u8fd4\u56de\u503c\u6ce8\u89e3\u4e3a&nbsp;<code>str<\/code>&nbsp;\u662f\u4e0d\u80fd\u51c6\u786e\u8868\u8fbe\u6b64\u60c5\u51b5\u7684\u3002<\/p>\n\n\n\n<p>\u8fd9\u79cd\u201c\u53ef\u80fd\u6709\u4e5f\u53ef\u80fd\u6ca1\u6709\u201d\u7684\u72b6\u6001\u88ab\u79f0\u4e3a<strong>\u53ef\u9009\u503c<\/strong>\uff0c\u5728\u67d0\u4e9b\u9879\u76ee\u4e2d\u975e\u5e38\u5e38\u89c1\u3002\u6bd4\u5982 web \u5e94\u7528\u4e2d\u67d0\u4e2a\u51fd\u6570\u63a5\u53d7\u8d26\u53f7\u548c\u5bc6\u7801\u4f5c\u4e3a\u53c2\u6570\uff0c\u5982\u679c\u5339\u914d\u5219\u8fd4\u56de\u7528\u6237\u5bf9\u8c61\uff0c\u82e5\u4e0d\u5339\u914d\u5219\u8fd4\u56de&nbsp;<code>None<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p>\u56e0\u6b64\uff0c\u6709\u4e13\u95e8\u7684\u53ef\u9009\u503c\u7c7b\u578b\u6ce8\u89e3\u53ef\u4ee5\u5904\u7406\u8fd9\u79cd\u60c5\u51b5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Optional\n\ndef foo(a: int = 0) -&gt; Optional[str]:\n    if a == 1:\n        return 'Yeah'\n<\/pre>\n\n\n\n<h3 id=\"union\">Union<\/h3>\n\n\n\n<p>\u6bd4&nbsp;<code>Optional<\/code>&nbsp;\u6db5\u76d6\u9762\u66f4\u5e7f\u7684\u662f&nbsp;<code>Union<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u51fd\u6570\u7684\u8fd4\u56de\u503c\u662f\u591a\u79cd\u7c7b\u578b\u4e2d\u7684\u4e00\u79cd\u65f6\uff0c\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Union\n\ndef foo() -&gt; Union[str, int, float]:\n    # ....\n    # some code here\n<\/pre>\n\n\n\n<p>\u4e0a\u9762\u8fd9\u4e2a\u51fd\u6570\u53ef\u4ee5\u8fd4\u56de\u5b57\u7b26\u4e32\u3001\u6574\u578b\u3001\u6d6e\u70b9\u578b\u4e2d\u7684\u4efb\u610f\u4e00\u79cd\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u53d1\u73b0&nbsp;<code>Optional<\/code>&nbsp;\u5b9e\u9645\u4e0a\u662f&nbsp;<code>Union<\/code>&nbsp;\u7684\u7279\u4f8b\uff1a<code>Optional[X]<\/code>&nbsp;\u548c&nbsp;<code>Union[X, None]<\/code>&nbsp;\u662f\u7b49\u4ef7\u7684\u3002<\/p>\n\n\n\n<h3 id=\"callable\">Callable<\/h3>\n\n\n\n<p>\u6211\u4eec\u77e5\u9053\uff0c Python \u4e2d\u7684\u51fd\u6570\u548c\u7c7b\u7684\u533a\u522b\u5e76\u4e0d\u660e\u663e\u3002\u53ea\u8981\u5b9e\u73b0\u4e86\u5bf9\u5e94\u7684\u63a5\u53e3\uff0c\u7c7b\u5b9e\u4f8b\u4e5f\u53ef\u4ee5\u662f<strong>\u53ef\u8c03\u7528\u7684<\/strong>\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4e0d\u5173\u5fc3\u5bf9\u8c61\u7684\u5177\u4f53\u7c7b\u578b\uff0c\u53ea\u8981\u6c42\u662f\u53ef\u8c03\u7528\u7684\uff0c\u90a3\u4e48\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Callable\n\nclass Foo:\n    def __call__(self):\n        print('I am foo')\n\ndef bar():\n    print('I am bar')\n\n\ndef hello(a: Callable):\n    a()\n\n# \u7c7b\u578b\u68c0\u67e5\u901a\u8fc7\nhello(Foo())\n# \u540c\u6837\u901a\u8fc7\nhello(bar)\n<\/pre>\n\n\n\n<h3 id=\"literal\">Literal<\/h3>\n\n\n\n<p>\u5373\u5b57\u9762\u91cf\u3002\u5b83\u5728\u5b9a\u4e49\u7b80\u5355\u7684\u679a\u4e3e\u503c\u65f6\u975e\u5e38\u597d\u7528\uff0c\u6bd4\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Literal\n\nMODE = Literal['r', 'rb', 'w', 'wb']\ndef open_helper(file: str, mode: MODE) -&gt; str:\n    ...\n\nopen_helper('\/some\/path', 'r')  # \u6210\u529f\nopen_helper('\/other\/path', 'typo')  # \u5931\u8d25\n<\/pre>\n\n\n\n<h3 id=\"protocol\">Protocol<\/h3>\n\n\n\n<p>\u5373<strong>\u534f\u8bae<\/strong>\u3002\u6211\u4eec\u901a\u5e38\u8bf4\u4e00\u4e2a\u5bf9\u8c61\u9075\u5b88\u4e86\u67d0\u4e2a\u201d\u534f\u8bae\u201c\uff0c\u610f\u601d\u662f\u8fd9\u4e2a\u5bf9\u8c61\u5b9e\u73b0\u4e86\u201d\u534f\u8bae\u201c\u4e2d\u89c4\u5b9a\u7684\u5c5e\u6027\u6216\u8005\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Protocol\n\nclass Proto(Protocol):\n    def foo(self):\n        print('I am proto')\n\nclass A:\n    def foo(self):\n        print('I am A')\n\nclass B:\n    def bar(self):\n        print('I am B')\n\ndef yeah(a: Proto):\n    pass\n\n# \u901a\u8fc7\uff0cA \u5b9e\u73b0\u4e86\u534f\u8bae\u4e2d\u7684 foo() \u65b9\u6cd5\nyeah(A())\n# \u4e0d\u901a\u8fc7\uff0cB \u672a\u5b9e\u73b0 foo()\nyeah(B())\n<\/pre>\n\n\n\n<h3 id=\"any\">Any<\/h3>\n\n\n\n<p>\u5982\u679c\u4f60\u5b9e\u5728\u4e0d\u77e5\u9053\u67d0\u4e2a\u7c7b\u578b\u6ce8\u89e3\u5e94\u8be5\u600e\u4e48\u5199\u65f6\uff0c\u8fd9\u91cc\u8fd8\u6709\u4e2a\u6700\u540e\u7684\u9003\u751f\u901a\u9053\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Any\n\ndef foo() -&gt; Any:\n    pass\n<\/pre>\n\n\n\n<p>\u4efb\u4f55\u7c7b\u578b\u90fd\u4e0e&nbsp;<code>Any<\/code>&nbsp;\u517c\u5bb9\u3002\u5f53\u7136\u5982\u679c\u4f60\u628a\u6240\u6709\u7684\u7c7b\u578b\u90fd\u6ce8\u89e3\u4e3a&nbsp;<code>Any<\/code>&nbsp;\u5c06\u6beb\u65e0\u610f\u4e49\uff0c\u56e0\u6b64&nbsp;<code>Any<\/code>&nbsp;\u5e94\u5f53\u5c3d\u91cf\u5c11\u4f7f\u7528\u3002<\/p>\n\n\n\n<h2 id=\"_6\">\u6cdb\u578b<\/h2>\n\n\n\n<p>\u8981\u7406\u89e3<strong>\u6cdb\u578b<\/strong>\uff0c\u9996\u5148\u5f97\u77e5\u9053\u6ca1\u6709\u5b83\u65f6\u6240\u9047\u5230\u7684\u9ebb\u70e6\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe\u6709\u4e00\u4e2a\u51fd\u6570\uff0c\u8981\u6c42\u5b83\u65e2\u80fd\u591f\u5904\u7406\u5b57\u7b26\u4e32\uff0c\u53c8\u80fd\u591f\u5904\u7406\u6570\u5b57\u3002\u90a3\u4e48\u4f60\u53ef\u80fd\u5f88\u81ea\u7136\u5730\u60f3\u5230\u4e86&nbsp;<code>Union<\/code>&nbsp;\u3002<\/p>\n\n\n\n<p>\u4e8e\u662f\u5199\u51fa\u7b2c\u4e00\u7248\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Union, List\n\nU = Union[str, int]\n\ndef foo(a: U, b: U) -&gt; List[U]:\n    return [a, b]\n<\/pre>\n\n\n\n<p>\u8fd9\u6837\u5199\u6709\u4e2a\u5f88\u5927\u7684\u5f0a\u7aef\uff0c\u5c31\u662f\u53c2\u6570\u7684\u7c7b\u578b\u53ef\u4ee5\u6df7\u7740\u7528\uff08\u6bd4\u5982&nbsp;<code>a: int<\/code>&nbsp;\u4e14&nbsp;<code>b:str<\/code>&nbsp;\uff09\uff0c\u5373\u4fbf\u4f60\u5e76\u4e0d\u60f3\u5177\u6709\u8fd9\u6837\u7684\u7279\u6027\u3002\u770b\u4e0b\u9762\u8fd9\u4e2a\u5c31\u660e\u767d\u4e86\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u7c7b\u578b\u68c0\u67e5\u901a\u8fc7\n# \u56e0\u4e3a Union[str, int] \u53ef\u4ee5\u662f\u5176\u4e2d\u4efb\u610f\u4e00\u79cd\u7c7b\u578b\n# \u5373\u4fbf\u4f60\u5e76\u4e0d\u60f3\u5c06 str \u548c int \u6df7\u7528\nfoo('Joe', 19)\n\n# \u901a\u8fc7\nfoo(19, 21)\n\n# \u901a\u8fc7\nfoo('Joe', 'David')\n<\/pre>\n\n\n\n<p><strong>\u6cdb\u578b<\/strong>\u5c31\u53ef\u4ee5\u89e3\u51b3\u6b64\u95ee\u9898\u3002\u6765\u770b\u7b2c\u4e8c\u7248\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import TypeVar, List\n\n# \u5b9a\u4e49\u6cdb\u578b T\n# T \u5fc5\u987b\u662f str \u6216 int \u5176\u4e2d\u4e00\u79cd\nT = TypeVar('T', str, int)\n\ndef bar(a: T, b: T) -&gt; List[T]:\n    return [a, b]\n\n# \u7c7b\u578b\u68c0\u67e5\u4e0d\u901a\u8fc7\n# \u51fd\u6570\u7684\u53c2\u6570\u5fc5\u987b\u4e3a\u540c\u4e00\u4e2a\u7c7b\u578b\"T\"\nbar('Joe', 19)\n\n# \u901a\u8fc7\nbar(19, 21)\n\n# \u901a\u8fc7\nbar('Joe', 'David')\n<\/pre>\n\n\n\n<p>\u53ef\u4ee5\u770b\u51fa\uff0c\u6cdb\u578b\u7c7b\u4f3c\u4e8e\u67d0\u79cd\u6a21\u677f\uff08\u6216\u8005\u5360\u4f4d\u7b26\uff09\uff0c\u5b83\u53ef\u4ee5\u5f88\u7cbe\u786e\u5730\u5c06\u5bf9\u8c61\u9650\u5b9a\u5728\u4f60\u771f\u6b63\u9700\u8981\u7684\u7c7b\u578b\u3002<\/p>\n\n\n\n<p>\u8ba9\u6211\u4eec\u518d\u770b\u770b\u4e0b\u9762\u8fd9\u4e2a\u5bf9\u6cdb\u578b\u7684\u5e94\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">from typing import Dict, TypeVar\n\n# \u5b9a\u4e49\u6cdb\u578b K \u548c V\n# K \u548c V \u7684\u5177\u4f53\u7c7b\u578b\u6ca1\u6709\u9650\u5236\nK = TypeVar(\"K\")\nV = TypeVar(\"V\")\n\ndef get_item(key: K, container: Dict[K, V]) -&gt; V:\n    return container[key]\n\n\ndict_1 = {\"age\": 10}\ndict_2 = {99: \"dusai\"}\n\nprint(get_item(\"age\", dict_1))\n# \u4f8b1\n# \u7c7b\u578b\u68c0\u67e5\u901a\u8fc7\uff0c\u8f93\u51fa: 10\n\nprint(get_item(99, dict_2))\n# \u4f8b2\n# \u7c7b\u578b\u68c0\u67e5\u901a\u8fc7\uff0c\u8f93\u51fa: dusai\n\nprint(get_item(\"name\", dict_2))\n# \u4f8b3\n# \u7c7b\u578b\u68c0\u67e5\u5931\u8d25\n# \u56e0\u4e3a\"name\"\u662f\u5b57\u7b26\u4e32\uff0c\u800cdict_2\u7684\u952e\u4e3a\u6574\u578b\n<\/pre>\n\n\n\n<ul><li>\u4ee3\u7801\u4e2d\u5b9a\u4e49\u4e86\u4e24\u4e2a\u6cdb\u578b K \u548c V\uff0c\u5bf9\u5b83\u4e24\u7684\u7c7b\u578b\u6ca1\u6709\u505a\u4efb\u4f55\u9650\u5236\uff0c\u4e5f\u5c31\u662f\u8bf4\u53ef\u4ee5\u662f\u4efb\u610f\u7c7b\u578b\u3002<\/li><li>\u51fd\u6570&nbsp;<code>get_item()<\/code>&nbsp;\u63a5\u53d7\u4e24\u4e2a\u53c2\u6570\u3002\u8fd9\u4e2a\u51fd\u6570\u4e0d\u5173\u5fc3\u53c2\u6570&nbsp;<code>container<\/code>&nbsp;\u5b57\u5178\u7684\u952e\u662f\u4ec0\u4e48\u7c7b\u578b\uff0c\u6216\u8005\u5b57\u5178\u7684\u503c\u662f\u4ec0\u4e48\u7c7b\u578b\uff1b\u4f46\u5b83\u7684\u53c2\u6570&nbsp;<code>container<\/code>&nbsp;\u5fc5\u987b\u662f\u5b57\u5178\uff0c\u53c2\u6570&nbsp;<code>key<\/code>&nbsp;\u5fc5\u987b\u4e0e\u5b57\u5178\u7684\u952e\u4e3a\u540c\u7c7b\u578b\uff0c\u5e76\u4e14\u8fd4\u56de\u503c\u548c\u5b57\u5178\u7684\u503c\u5fc5\u987b\u4e3a\u540c\u7c7b\u578b\u3002\u4ec5\u4ec5\u901a\u8fc7\u67e5\u770b\u51fd\u6570\u7684\u7c7b\u578b\u6ce8\u89e3\uff0c\u5c31\u53ef\u4ee5\u83b7\u5f97\u6240\u6709\u8fd9\u4e9b\u4fe1\u606f\u3002<\/li><\/ul>\n\n\n\n<p>\u91cd\u70b9\u6765\u770b\u4e0b<em>\u4f8b3<\/em>\u7684\u7c7b\u578b\u68c0\u67e5\u4e3a\u4ec0\u4e48\u4f1a<strong>\u5931\u8d25<\/strong>\uff1a<\/p>\n\n\n\n<ul><li><code>dict_2<\/code>&nbsp;\u5b9a\u4e49\u65f6\uff0c\u5176\u952e\u88ab\u5b9a\u4e49\u4e3a\u6574\u578b\u3002<\/li><li><code>get_item(\"name\", dict_2)<\/code>&nbsp;\u8c03\u7528\u65f6\uff0c<code>\"name\"<\/code>&nbsp;\u4e3a\u5b57\u7b26\u4e32\uff0c\u800c&nbsp;<code>dict_2<\/code>&nbsp;\u7684\u952e\u4e3a\u6574\u578b\uff0c\u7c7b\u578b\u4e0d\u4e00\u81f4\u3002\u800c\u7c7b\u578b\u6ce8\u89e3\u4e2d\u6e05\u695a\u8868\u660e\u5b83\u4e24\u5e94\u8be5\u4e3a\u540c\u4e00\u4e2a\u7c7b\u578b&nbsp;<code>K<\/code>&nbsp;\uff0c\u4ea7\u751f\u51b2\u7a81\u3002<\/li><li>\u7f16\u8f91\u5668\u5bdf\u89c9\u5230\u51b2\u7a81\uff0c\u53cb\u597d\u5730\u63d0\u793a\u4f60\uff0c\u8fd9\u91cc\u53ef\u80fd\u51fa\u9519\u4e86\u3002<\/li><\/ul>\n\n\n\n<p>\u6cdb\u578b\u5f88\u5de7\u5999\u5730<strong>\u5bf9\u7c7b\u578b\u8fdb\u884c\u4e86\u53c2\u6570\u5316<\/strong>\uff0c\u540c\u65f6\u53c8\u4fdd\u7559\u4e86\u51fd\u6570\u5904\u7406\u4e0d\u540c\u7c7b\u578b\u65f6\u7684\u7075\u6d3b\u6027\u3002<\/p>\n\n\n\n<p>\u518d\u56de\u8fc7\u5934\u6765\u770b\u770b\u7c7b\u578b\u6ce8\u89e3\u7684\u4f5c\u7528\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def get_item(key: K, container: Dict[K, V]) -&gt; V:\n    # ...\n\ndef get_item(key, container):\n    # ...\n<\/pre>\n\n\n\n<p>\u4e0a\u9762\u4e24\u4e2a\u51fd\u6570\u529f\u80fd\u5b8c\u5168\u76f8\u540c\uff0c\u4f46\u662f\u6ca1\u6709\u7c7b\u578b\u6ce8\u89e3\u7684\u90a3\u4e2a\uff0c\u663e\u7136\u9700\u8981\u82b1\u66f4\u591a\u7684\u65f6\u95f4\u9605\u8bfb\u51fd\u6570\u5185\u90e8\u7684\u4ee3\u7801\uff0c\u53bb\u786e\u8ba4\u51fd\u6570\u5230\u5e95\u5e72\u4e86\u4ec0\u4e48\u3002\u5e76\u4e14\u5b83\u4e5f\u65e0\u6cd5\u5229\u7528\u7f16\u8f91\u5668\u7684\u7c7b\u578b\u68c0\u67e5\uff0c\u5728\u65e9\u671f\u5e2e\u52a9\u6392\u9664\u4e00\u4e9b\u4f4e\u7ea7\u9519\u8bef\u3002<\/p>\n\n\n\n<h2 id=\"_7\">\u603b\u7ed3<\/h2>\n\n\n\n<p>\u6700\u540e\u518d\u603b\u7ed3\u4e0b\uff0cPython \u793e\u533a\u4e3a\u4ec0\u4e48\u82b1\u4e86\u5f88\u5927\u529b\u6c14\uff0c\u53bb\u5b9e\u73b0\u4e86\u7c7b\u578b\u6ce8\u89e3\u8fd9\u4e2a\u4ec5\u4ec5\u8d77\u201d\u63d0\u793a\u4f5c\u7528\u201c\u7684\u529f\u80fd\uff1a<\/p>\n\n\n\n<ul><li>\u8ba9\u4ee3\u7801\u6a21\u5757\u7684\u529f\u80fd\u66f4\u6e05\u6670\u3002<\/li><li>\u8ba9\u7f16\u8f91\u5668\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5c3d\u65e9\u53d1\u73b0\u95ee\u9898\u3002<\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u81ea\uff1ahttps:\/\/www.cnblogs.com\/xzkzzz\/p\/11378842.html \u5728 Pyt &hellip; <a href=\"http:\/\/139.9.1.231\/index.php\/2021\/12\/20\/python\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Python 3 \u65b0\u7279\u6027\uff1a\u7c7b\u578b\u6ce8\u89e3<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/424"}],"collection":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/comments?post=424"}],"version-history":[{"count":4,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/424\/revisions"}],"predecessor-version":[{"id":428,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/posts\/424\/revisions\/428"}],"wp:attachment":[{"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/media?parent=424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/categories?post=424"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/139.9.1.231\/index.php\/wp-json\/wp\/v2\/tags?post=424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}