{"id":1066479,"date":"2024-12-31T16:26:41","date_gmt":"2024-12-31T08:26:41","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1066479.html"},"modified":"2024-12-31T16:26:44","modified_gmt":"2024-12-31T08:26:44","slug":"python%e6%98%af%e5%a6%82%e4%bd%95%e8%af%86%e5%88%ab%e8%bf%90%e7%ae%97%e7%ac%a6%e7%9a%84","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1066479.html","title":{"rendered":"python\u662f\u5982\u4f55\u8bc6\u522b\u8fd0\u7b97\u7b26\u7684"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/30581f96-cadc-485f-84fe-d9bc6f9ae561.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u662f\u5982\u4f55\u8bc6\u522b\u8fd0\u7b97\u7b26\u7684\" \/><\/p>\n<p><p> <strong>Python\u8bc6\u522b\u8fd0\u7b97\u7b26\u7684\u65b9\u5f0f\u662f\u901a\u8fc7\u89e3\u91ca\u5668\u89e3\u6790\u4ee3\u7801\u3001\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u3001\u8fd0\u7b97\u7b26\u91cd\u8f7d\u3001\u8fd0\u7b97\u7b26\u51fd\u6570\u5b9e\u73b0\u3002<\/strong> \u5176\u4e2d\uff0c\u89e3\u91ca\u5668\u89e3\u6790\u4ee3\u7801\u662f\u6700\u57fa\u7840\u7684\u4e00\u70b9\u3002Python\u89e3\u91ca\u5668\u5728\u6267\u884c\u4ee3\u7801\u65f6\uff0c\u4f1a\u9010\u884c\u89e3\u6790\u4ee3\u7801\uff0c\u5bf9\u4e8e\u6bcf\u4e00\u884c\u4ee3\u7801\uff0c\u89e3\u91ca\u5668\u4f1a\u901a\u8fc7\u8bcd\u6cd5\u5206\u6790\u548c\u8bed\u6cd5\u5206\u6790\u6765\u8bc6\u522b\u51fa\u8fd0\u7b97\u7b26\uff0c\u5e76\u6839\u636e\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u6765\u51b3\u5b9a\u8fd0\u7b97\u987a\u5e8f\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u89e3\u91ca\u5668\u89e3\u6790\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>Python\u89e3\u91ca\u5668\u5728\u6267\u884c\u4ee3\u7801\u65f6\uff0c\u901a\u8fc7\u8bcd\u6cd5\u5206\u6790\u548c\u8bed\u6cd5\u5206\u6790\u6765\u89e3\u6790\u4ee3\u7801\u3002\u8bcd\u6cd5\u5206\u6790\u5c06\u4ee3\u7801\u62c6\u5206\u6210\u6700\u5c0f\u7684\u5355\u5143\uff08Token\uff09\uff0c\u5982\u5173\u952e\u5b57\u3001\u6807\u8bc6\u7b26\u3001\u8fd0\u7b97\u7b26\u7b49\u3002\u800c\u8bed\u6cd5\u5206\u6790\u5219\u662f\u5c06\u8fd9\u4e9bToken\u6309\u7167\u4e00\u5b9a\u7684\u8bed\u6cd5\u89c4\u5219\u7ec4\u6210\u8bed\u6cd5\u6811\uff0c\u5e76\u636e\u6b64\u751f\u6210\u53ef\u6267\u884c\u7684\u4ee3\u7801\u3002<strong>\u89e3\u91ca\u5668\u5728\u89e3\u6790\u4ee3\u7801\u65f6\uff0c\u4f1a\u6839\u636e\u8fd0\u7b97\u7b26\u7684\u5b9a\u4e49\u6765\u8bc6\u522b\u4e0d\u540c\u7684\u8fd0\u7b97\u7b26\uff0c\u5e76\u6839\u636e\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u6765\u51b3\u5b9a\u8fd0\u7b97\u987a\u5e8f\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u8bcd\u6cd5\u5206\u6790\u5668\u4f1a\u9996\u5148\u8bc6\u522b\u8fd0\u7b97\u7b26\u7684\u5b57\u7b26\uff0c\u7136\u540e\u5c06\u5176\u6807\u8bb0\u4e3a\u7279\u5b9a\u7684\u8fd0\u7b97\u7b26Token\u3002\u8bed\u6cd5\u5206\u6790\u5668\u5219\u4f1a\u6839\u636e\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u548c\u7ed3\u5408\u6027\u6765\u6784\u5efa\u8bed\u6cd5\u6811\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u8868\u8fbe\u5f0f <code>3 + 4 * 5<\/code>\uff0c\u89e3\u91ca\u5668\u4f1a\u5148\u8bc6\u522b\u51fa\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code> \u548c\u4e58\u6cd5\u8fd0\u7b97\u7b26 <code>*<\/code>\uff0c\u7136\u540e\u6839\u636e\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\uff08\u4e58\u6cd5\u4f18\u5148\u7ea7\u9ad8\u4e8e\u52a0\u6cd5\uff09\uff0c\u51b3\u5b9a\u5148\u8fdb\u884c\u4e58\u6cd5\u8fd0\u7b97\uff0c\u518d\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7<\/h3>\n<\/p>\n<p><p>Python\u4e2d\u7684\u8fd0\u7b97\u7b26\u6709\u4e0d\u540c\u7684\u4f18\u5148\u7ea7\uff0c\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u8fd0\u7b97\u7684\u987a\u5e8f\u3002\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u53ef\u4ee5\u901a\u8fc7\u67e5\u9605Python\u7684\u5b98\u65b9\u6587\u6863\u6765\u4e86\u89e3\u3002\u5e38\u89c1\u7684\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u4ece\u9ad8\u5230\u4f4e\u6392\u5217\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u62ec\u53f7 <code>()<\/code><\/li>\n<li>\u6307\u6570 <code><\/code><\/li>\n<li>\u53d6\u6b63\u8d1f\u53f7 <code>+ -<\/code><\/li>\n<li>\u4e58\u6cd5\u3001\u9664\u6cd5\u3001\u53d6\u4f59\u3001\u53d6\u6574 <code>* \/ % \/\/<\/code><\/li>\n<li>\u52a0\u6cd5\u3001\u51cf\u6cd5 <code>+ -<\/code><\/li>\n<li>\u4f4d\u79fb\u8fd0\u7b97\u7b26 <code>&lt;&lt; &gt;&gt;<\/code><\/li>\n<li>\u6309\u4f4d\u4e0e <code>&amp;<\/code><\/li>\n<li>\u6309\u4f4d\u5f02\u6216 <code>^<\/code><\/li>\n<li>\u6309\u4f4d\u6216 <code>|<\/code><\/li>\n<li>\u6bd4\u8f83\u8fd0\u7b97\u7b26 <code>&lt; &lt;= &gt; &gt;=<\/code><\/li>\n<li>\u7b49\u503c\u8fd0\u7b97\u7b26 <code>== !=<\/code><\/li>\n<li>\u8d4b\u503c\u8fd0\u7b97\u7b26 <code>= += -= *= \/= %= \/\/= = &amp;= ^= |= &lt;&lt;= &gt;&gt;=<\/code><\/li>\n<\/ol>\n<p><p><strong>\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u51b3\u5b9a\u4e86\u5728\u6ca1\u6709\u4f7f\u7528\u62ec\u53f7\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd0\u7b97\u7b26\u7684\u8ba1\u7b97\u987a\u5e8f\u3002<\/strong> \u62ec\u53f7\u8fd0\u7b97\u7b26\u5177\u6709\u6700\u9ad8\u7684\u4f18\u5148\u7ea7\uff0c\u53ef\u4ee5\u6539\u53d8\u9ed8\u8ba4\u7684\u8fd0\u7b97\u987a\u5e8f\u3002\u4f8b\u5982\uff0c\u8868\u8fbe\u5f0f <code>3 + 4 * 2<\/code> \u5728\u6ca1\u6709\u62ec\u53f7\u7684\u60c5\u51b5\u4e0b\uff0c\u4f1a\u5148\u8ba1\u7b97 <code>4 * 2<\/code>\uff0c\u518d\u52a0\u4e0a <code>3<\/code>\uff0c\u7ed3\u679c\u662f <code>11<\/code>\u3002\u5982\u679c\u52a0\u4e0a\u62ec\u53f7 <code>(3 + 4) * 2<\/code>\uff0c\u5219\u4f1a\u5148\u8ba1\u7b97\u62ec\u53f7\u5185\u7684 <code>3 + 4<\/code>\uff0c\u518d\u4e58\u4ee5 <code>2<\/code>\uff0c\u7ed3\u679c\u662f <code>14<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u8fd0\u7b97\u7b26\u91cd\u8f7d<\/h3>\n<\/p>\n<p><p>Python\u652f\u6301\u8fd0\u7b97\u7b26\u91cd\u8f7d\uff0c\u5373\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u7279\u6b8a\u65b9\u6cd5\u6765\u6539\u53d8\u8fd0\u7b97\u7b26\u7684\u884c\u4e3a\u3002\u4f8b\u5982\uff0c\u901a\u8fc7\u5b9a\u4e49\u7279\u6b8a\u65b9\u6cd5 <code>__add__<\/code>\uff0c\u53ef\u4ee5\u91cd\u8f7d\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code>\u3002\u8fd0\u7b97\u7b26\u91cd\u8f7d\u4f7f\u5f97\u81ea\u5b9a\u4e49\u7684\u7c7b\u53ef\u4ee5\u50cf\u5185\u7f6e\u7c7b\u578b\u4e00\u6837\u4f7f\u7528\u8fd0\u7b97\u7b26\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u91cd\u8f7d\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Vector:<\/p>\n<p>    def __init__(self, x, y):<\/p>\n<p>        self.x = x<\/p>\n<p>        self.y = y<\/p>\n<p>    def __add__(self, other):<\/p>\n<p>        return Vector(self.x + other.x, self.y + other.y)<\/p>\n<p>    def __repr__(self):<\/p>\n<p>        return f&quot;Vector({self.x}, {self.y})&quot;<\/p>\n<p>v1 = Vector(1, 2)<\/p>\n<p>v2 = Vector(3, 4)<\/p>\n<p>v3 = v1 + v2<\/p>\n<p>print(v3)  # \u8f93\u51fa\uff1aVector(4, 6)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a <code>Vector<\/code> \u7c7b\uff0c\u5e76\u91cd\u8f7d\u4e86\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code>\u3002\u5f53\u4e24\u4e2a <code>Vector<\/code> \u5bf9\u8c61\u76f8\u52a0\u65f6\uff0c\u4f1a\u8c03\u7528 <code>__add__<\/code> \u65b9\u6cd5\uff0c\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684 <code>Vector<\/code> \u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u8fd0\u7b97\u7b26\u51fd\u6570\u5b9e\u73b0<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u8fd0\u7b97\u7b26\u5b9e\u9645\u4e0a\u662f\u901a\u8fc7\u51fd\u6570\u6765\u5b9e\u73b0\u7684\u3002\u4f8b\u5982\uff0c\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code> \u5bf9\u5e94\u7684\u51fd\u6570\u662f <code>operator.add<\/code>\u3002Python\u6807\u51c6\u5e93\u4e2d\u7684 <code>operator<\/code> \u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u8fd0\u7b97\u7b26\u51fd\u6570\uff0c\u53ef\u4ee5\u76f4\u63a5\u8c03\u7528\u8fd9\u4e9b\u51fd\u6570\u6765\u8fdb\u884c\u8fd0\u7b97\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u4f7f\u7528 <code>operator<\/code> \u6a21\u5757\u4e2d\u7684\u8fd0\u7b97\u7b26\u51fd\u6570\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import operator<\/p>\n<p>a = 3<\/p>\n<p>b = 4<\/p>\n<p>result = operator.add(a, b)<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1a7<\/p>\n<p>result = operator.mul(a, b)<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1a12<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u4f7f\u7528 <code>operator.add<\/code> \u51fd\u6570\u8fdb\u884c\u52a0\u6cd5\u8fd0\u7b97\uff0c\u4f7f\u7528 <code>operator.mul<\/code> \u51fd\u6570\u8fdb\u884c\u4e58\u6cd5\u8fd0\u7b97\u3002\u8fd0\u7b97\u7b26\u51fd\u6570\u7684\u4f7f\u7528\u65b9\u5f0f\u4e0e\u76f4\u63a5\u4f7f\u7528\u8fd0\u7b97\u7b26\u76f8\u540c\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u8fd0\u7b97\u7b26\u7684\u7c7b\u578b<\/h3>\n<\/p>\n<p><p>Python\u4e2d\u7684\u8fd0\u7b97\u7b26\u53ef\u4ee5\u5206\u4e3a\u4ee5\u4e0b\u51e0\u7c7b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u7b97\u672f\u8fd0\u7b97\u7b26\uff1a\u5305\u62ec\u52a0\u6cd5 <code>+<\/code>\u3001\u51cf\u6cd5 <code>-<\/code>\u3001\u4e58\u6cd5 <code>*<\/code>\u3001\u9664\u6cd5 <code>\/<\/code>\u3001\u53d6\u4f59 <code>%<\/code>\u3001\u53d6\u6574 <code>\/\/<\/code>\u3001\u6307\u6570 <code><\/code>\u3002<\/li>\n<li>\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff1a\u5305\u62ec\u7b49\u4e8e <code>==<\/code>\u3001\u4e0d\u7b49\u4e8e <code>!=<\/code>\u3001\u5927\u4e8e <code>&gt;<\/code>\u3001\u5c0f\u4e8e <code>&lt;<\/code>\u3001\u5927\u4e8e\u7b49\u4e8e <code>&gt;=<\/code>\u3001\u5c0f\u4e8e\u7b49\u4e8e <code>&lt;=<\/code>\u3002<\/li>\n<li>\u903b\u8f91\u8fd0\u7b97\u7b26\uff1a\u5305\u62ec\u4e0e <code>and<\/code>\u3001\u6216 <code>or<\/code>\u3001\u975e <code>not<\/code>\u3002<\/li>\n<li>\u4f4d\u8fd0\u7b97\u7b26\uff1a\u5305\u62ec\u6309\u4f4d\u4e0e <code>&amp;<\/code>\u3001\u6309\u4f4d\u6216 <code>|<\/code>\u3001\u6309\u4f4d\u5f02\u6216 <code>^<\/code>\u3001\u6309\u4f4d\u53d6\u53cd <code>~<\/code>\u3001\u5de6\u79fb <code>&lt;&lt;<\/code>\u3001\u53f3\u79fb <code>&gt;&gt;<\/code>\u3002<\/li>\n<li>\u8d4b\u503c\u8fd0\u7b97\u7b26\uff1a\u5305\u62ec\u8d4b\u503c <code>=<\/code>\u3001\u52a0\u8d4b\u503c <code>+=<\/code>\u3001\u51cf\u8d4b\u503c <code>-=<\/code>\u3001\u4e58\u8d4b\u503c <code>*=<\/code>\u3001\u9664\u8d4b\u503c <code>\/=<\/code>\u3001\u53d6\u4f59\u8d4b\u503c <code>%=<\/code>\u3001\u53d6\u6574\u8d4b\u503c <code>\/\/=<\/code>\u3001\u6307\u6570\u8d4b\u503c <code>=<\/code>\u3002<\/li>\n<li>\u6210\u5458\u8fd0\u7b97\u7b26\uff1a\u5305\u62ec\u6210\u5458 <code>in<\/code>\u3001\u4e0d\u6210\u5458 <code>not in<\/code>\u3002<\/li>\n<li>\u8eab\u4efd\u8fd0\u7b97\u7b26\uff1a\u5305\u62ec\u8eab\u4efd <code>is<\/code>\u3001\u4e0d\u8eab\u4efd <code>is not<\/code>\u3002<\/li>\n<\/ol>\n<p><p><strong>\u6bcf\u79cd\u8fd0\u7b97\u7b26\u90fd\u6709\u5176\u7279\u5b9a\u7684\u7528\u9014\u548c\u4f7f\u7528\u89c4\u5219\u3002<\/strong> \u4f8b\u5982\uff0c\u7b97\u672f\u8fd0\u7b97\u7b26\u7528\u4e8e\u6570\u503c\u8fd0\u7b97\uff0c\u6bd4\u8f83\u8fd0\u7b97\u7b26\u7528\u4e8e\u6bd4\u8f83\u4e24\u4e2a\u503c\u7684\u5927\u5c0f\uff0c\u903b\u8f91\u8fd0\u7b97\u7b26\u7528\u4e8e\u903b\u8f91\u5224\u65ad\uff0c\u4f4d\u8fd0\u7b97\u7b26\u7528\u4e8e\u4f4d\u64cd\u4f5c\uff0c\u8d4b\u503c\u8fd0\u7b97\u7b26\u7528\u4e8e\u8d4b\u503c\u64cd\u4f5c\uff0c\u6210\u5458\u8fd0\u7b97\u7b26\u7528\u4e8e\u5224\u65ad\u5143\u7d20\u662f\u5426\u5728\u96c6\u5408\u4e2d\uff0c\u8eab\u4efd\u8fd0\u7b97\u7b26\u7528\u4e8e\u5224\u65ad\u4e24\u4e2a\u5bf9\u8c61\u662f\u5426\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u5e38\u89c1\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\u793a\u4f8b<\/h3>\n<\/p>\n<ol>\n<li>\u7b97\u672f\u8fd0\u7b97\u7b26<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 3<\/p>\n<p>print(a + b)  # \u8f93\u51fa\uff1a13<\/p>\n<p>print(a - b)  # \u8f93\u51fa\uff1a7<\/p>\n<p>print(a * b)  # \u8f93\u51fa\uff1a30<\/p>\n<p>print(a \/ b)  # \u8f93\u51fa\uff1a3.3333333333333335<\/p>\n<p>print(a % b)  # \u8f93\u51fa\uff1a1<\/p>\n<p>print(a \/\/ b)  # \u8f93\u51fa\uff1a3<\/p>\n<p>print(a  b)  # \u8f93\u51fa\uff1a1000<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u6bd4\u8f83\u8fd0\u7b97\u7b26<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 3<\/p>\n<p>print(a == b)  # \u8f93\u51fa\uff1aFalse<\/p>\n<p>print(a != b)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p>print(a &gt; b)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p>print(a &lt; b)  # \u8f93\u51fa\uff1aFalse<\/p>\n<p>print(a &gt;= b)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p>print(a &lt;= b)  # \u8f93\u51fa\uff1aFalse<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u903b\u8f91\u8fd0\u7b97\u7b26<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">a = True<\/p>\n<p>b = False<\/p>\n<p>print(a and b)  # \u8f93\u51fa\uff1aFalse<\/p>\n<p>print(a or b)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p>print(not a)  # \u8f93\u51fa\uff1aFalse<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li>\u4f4d\u8fd0\u7b97\u7b26<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">a = 10  # \u4e8c\u8fdb\u5236\uff1a1010<\/p>\n<p>b = 3   # \u4e8c\u8fdb\u5236\uff1a0011<\/p>\n<p>print(a &amp; b)  # \u8f93\u51fa\uff1a2  \u4e8c\u8fdb\u5236\uff1a0010<\/p>\n<p>print(a | b)  # \u8f93\u51fa\uff1a11 \u4e8c\u8fdb\u5236\uff1a1011<\/p>\n<p>print(a ^ b)  # \u8f93\u51fa\uff1a9  \u4e8c\u8fdb\u5236\uff1a1001<\/p>\n<p>print(~a)  # \u8f93\u51fa\uff1a-11<\/p>\n<p>print(a &lt;&lt; 1)  # \u8f93\u51fa\uff1a20<\/p>\n<p>print(a &gt;&gt; 1)  # \u8f93\u51fa\uff1a5<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"5\">\n<li>\u8d4b\u503c\u8fd0\u7b97\u7b26<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 3<\/p>\n<p>a += b<\/p>\n<p>print(a)  # \u8f93\u51fa\uff1a13<\/p>\n<p>a -= b<\/p>\n<p>print(a)  # \u8f93\u51fa\uff1a10<\/p>\n<p>a *= b<\/p>\n<p>print(a)  # \u8f93\u51fa\uff1a30<\/p>\n<p>a \/= b<\/p>\n<p>print(a)  # \u8f93\u51fa\uff1a10.0<\/p>\n<p>a %= b<\/p>\n<p>print(a)  # \u8f93\u51fa\uff1a1.0<\/p>\n<p>a \/\/= b<\/p>\n<p>print(a)  # \u8f93\u51fa\uff1a0.0<\/p>\n<p>a = b<\/p>\n<p>print(a)  # \u8f93\u51fa\uff1a0.0<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"6\">\n<li>\u6210\u5458\u8fd0\u7b97\u7b26<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">a = [1, 2, 3, 4, 5]<\/p>\n<p>print(3 in a)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p>print(6 not in a)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"7\">\n<li>\u8eab\u4efd\u8fd0\u7b97\u7b26<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">a = [1, 2, 3]<\/p>\n<p>b = a<\/p>\n<p>c = [1, 2, 3]<\/p>\n<p>print(a is b)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p>print(a is c)  # \u8f93\u51fa\uff1aFalse<\/p>\n<p>print(a is not c)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e03\u3001\u8fd0\u7b97\u7b26\u7684\u7ed3\u5408\u6027<\/h3>\n<\/p>\n<p><p>\u8fd0\u7b97\u7b26\u7684\u7ed3\u5408\u6027\u51b3\u5b9a\u4e86\u5728\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u76f8\u540c\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd0\u7b97\u7684\u987a\u5e8f\u3002Python\u4e2d\u7684\u5927\u591a\u6570\u8fd0\u7b97\u7b26\u662f\u5de6\u7ed3\u5408\u7684\uff0c\u5373\u4ece\u5de6\u5230\u53f3\u8fdb\u884c\u8fd0\u7b97\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u8868\u8fbe\u5f0f <code>a - b - c<\/code>\uff0c\u4f1a\u5148\u8ba1\u7b97 <code>a - b<\/code>\uff0c\u518d\u8ba1\u7b97\u7ed3\u679c\u51cf\u53bb <code>c<\/code>\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u4e86\u5de6\u7ed3\u5408\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = 10<\/p>\n<p>b = 3<\/p>\n<p>c = 2<\/p>\n<p>result = a - b - c<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1a5<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u8868\u8fbe\u5f0f <code>a - b - c<\/code> \u4f1a\u5148\u8ba1\u7b97 <code>a - b<\/code>\uff0c\u7ed3\u679c\u662f <code>7<\/code>\uff0c\u518d\u8ba1\u7b97 <code>7 - c<\/code>\uff0c\u7ed3\u679c\u662f <code>5<\/code>\u3002<\/p>\n<\/p>\n<p><p>Python\u4e2d\u7684\u6307\u6570\u8fd0\u7b97\u7b26 <code>&lt;strong&gt;<\/code> \u662f\u53f3\u7ed3\u5408\u7684\uff0c\u5373\u4ece\u53f3\u5230\u5de6\u8fdb\u884c\u8fd0\u7b97\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u8868\u8fbe\u5f0f <code>2 &lt;\/strong&gt; 3 &lt;strong&gt; 2<\/code>\uff0c\u4f1a\u5148\u8ba1\u7b97 <code>3 &lt;\/strong&gt; 2<\/code>\uff0c\u518d\u8ba1\u7b97 <code>2  9<\/code>\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u4e86\u53f3\u7ed3\u5408\u8fd0\u7b97\u7b26\u7684\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">result = 2 &lt;strong&gt; 3 &lt;\/strong&gt; 2<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1a512<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u8868\u8fbe\u5f0f <code>2 &lt;strong&gt; 3 &lt;\/strong&gt; 2<\/code> \u4f1a\u5148\u8ba1\u7b97 <code>3 &lt;strong&gt; 2<\/code>\uff0c\u7ed3\u679c\u662f <code>9<\/code>\uff0c\u518d\u8ba1\u7b97 <code>2 &lt;\/strong&gt; 9<\/code>\uff0c\u7ed3\u679c\u662f <code>512<\/code>\u3002<\/p>\n<\/p>\n<p><h3>\u516b\u3001\u8fd0\u7b97\u7b26\u7684\u77ed\u8def\u8fd0\u7b97<\/h3>\n<\/p>\n<p><p>Python\u4e2d\u7684\u903b\u8f91\u8fd0\u7b97\u7b26 <code>and<\/code> \u548c <code>or<\/code> \u652f\u6301\u77ed\u8def\u8fd0\u7b97\u3002\u77ed\u8def\u8fd0\u7b97\u6307\u7684\u662f\u5728\u903b\u8f91\u8868\u8fbe\u5f0f\u4e2d\uff0c\u4e00\u65e6\u786e\u5b9a\u4e86\u6574\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\uff0c\u5c31\u7acb\u5373\u505c\u6b62\u8ba1\u7b97\u540e\u7eed\u7684\u90e8\u5206\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u8868\u8fbe\u5f0f <code>a and b<\/code>\uff0c\u5982\u679c <code>a<\/code> \u7684\u503c\u4e3a <code>False<\/code>\uff0c\u5219\u6574\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u4e00\u5b9a\u4e3a <code>False<\/code>\uff0c\u6b64\u65f6\u4e0d\u4f1a\u518d\u8ba1\u7b97 <code>b<\/code> \u7684\u503c\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u4e86\u77ed\u8def\u8fd0\u7b97\u7684\u4f7f\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = False<\/p>\n<p>b = True<\/p>\n<p>result = a and b<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1aFalse<\/p>\n<p>a = True<\/p>\n<p>result = a or b<\/p>\n<p>print(result)  # \u8f93\u51fa\uff1aTrue<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u8868\u8fbe\u5f0f <code>a and b<\/code> \u7684 <code>a<\/code> \u4e3a <code>False<\/code>\uff0c\u56e0\u6b64\u6574\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u4e3a <code>False<\/code>\uff0c\u4e0d\u4f1a\u518d\u8ba1\u7b97 <code>b<\/code> \u7684\u503c\u3002\u8868\u8fbe\u5f0f <code>a or b<\/code> \u7684 <code>a<\/code> \u4e3a <code>True<\/code>\uff0c\u56e0\u6b64\u6574\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u4e3a <code>True<\/code>\uff0c\u4e0d\u4f1a\u518d\u8ba1\u7b97 <code>b<\/code> \u7684\u503c\u3002<\/p>\n<\/p>\n<p><h3>\u4e5d\u3001\u8fd0\u7b97\u7b26\u7684\u91cd\u8f7d\u548c\u81ea\u5b9a\u4e49<\/h3>\n<\/p>\n<p><p>Python\u4e2d\u7684\u8fd0\u7b97\u7b26\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u7279\u6b8a\u65b9\u6cd5\u6765\u91cd\u8f7d\u548c\u81ea\u5b9a\u4e49\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u7279\u6b8a\u65b9\u6cd5 <code>__add__<\/code> \u6765\u91cd\u8f7d\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code>\uff0c\u901a\u8fc7\u5b9a\u4e49\u7279\u6b8a\u65b9\u6cd5 <code>__mul__<\/code> \u6765\u91cd\u8f7d\u4e58\u6cd5\u8fd0\u7b97\u7b26 <code>*<\/code>\u3002<\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u4e86\u5982\u4f55\u91cd\u8f7d\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class Vector:<\/p>\n<p>    def __init__(self, x, y):<\/p>\n<p>        self.x = x<\/p>\n<p>        self.y = y<\/p>\n<p>    def __add__(self, other):<\/p>\n<p>        return Vector(self.x + other.x, self.y + other.y)<\/p>\n<p>    def __repr__(self):<\/p>\n<p>        return f&quot;Vector({self.x}, {self.y})&quot;<\/p>\n<p>v1 = Vector(1, 2)<\/p>\n<p>v2 = Vector(3, 4)<\/p>\n<p>v3 = v1 + v2<\/p>\n<p>print(v3)  # \u8f93\u51fa\uff1aVector(4, 6)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5b9a\u4e49\u4e86\u4e00\u4e2a <code>Vector<\/code> \u7c7b\uff0c\u5e76\u91cd\u8f7d\u4e86\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code>\u3002\u5f53\u4e24\u4e2a <code>Vector<\/code> \u5bf9\u8c61\u76f8\u52a0\u65f6\uff0c\u4f1a\u8c03\u7528 <code>__add__<\/code> \u65b9\u6cd5\uff0c\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684 <code>Vector<\/code> \u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u3001\u8fd0\u7b97\u7b26\u7684\u6700\u4f73\u5b9e\u8df5<\/h3>\n<\/p>\n<ol>\n<li>\u4f7f\u7528\u62ec\u53f7\u660e\u786e\u8fd0\u7b97\u987a\u5e8f<\/li>\n<\/ol>\n<p><p>\u5728\u590d\u6742\u7684\u8868\u8fbe\u5f0f\u4e2d\uff0c\u4f7f\u7528\u62ec\u53f7\u53ef\u4ee5\u660e\u786e\u8fd0\u7b97\u7684\u987a\u5e8f\uff0c\u907f\u514d\u6b67\u4e49\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u8868\u8fbe\u5f0f <code>3 + 4 * 2<\/code>\uff0c\u53ef\u4ee5\u4f7f\u7528\u62ec\u53f7 <code>(3 + 4) * 2<\/code> \u6765\u660e\u786e\u8fd0\u7b97\u987a\u5e8f\u3002<\/p>\n<\/p>\n<ol start=\"2\">\n<li>\u907f\u514d\u6df7\u5408\u4f7f\u7528\u4e0d\u540c\u7c7b\u578b\u7684\u8fd0\u7b97\u7b26<\/li>\n<\/ol>\n<p><p>\u5728\u8868\u8fbe\u5f0f\u4e2d\uff0c\u5c3d\u91cf\u907f\u514d\u6df7\u5408\u4f7f\u7528\u4e0d\u540c\u7c7b\u578b\u7684\u8fd0\u7b97\u7b26\uff0c\u4ee5\u51cf\u5c11\u9519\u8bef\u548c\u63d0\u9ad8\u53ef\u8bfb\u6027\u3002\u4f8b\u5982\uff0c\u907f\u514d\u5728\u540c\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e2d\u540c\u65f6\u4f7f\u7528\u7b97\u672f\u8fd0\u7b97\u7b26\u548c\u4f4d\u8fd0\u7b97\u7b26\u3002<\/p>\n<\/p>\n<ol start=\"3\">\n<li>\u5229\u7528\u8fd0\u7b97\u7b26\u91cd\u8f7d\u548c\u81ea\u5b9a\u4e49<\/li>\n<\/ol>\n<p><p>\u5728\u81ea\u5b9a\u4e49\u7c7b\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u8fd0\u7b97\u7b26\u91cd\u8f7d\u548c\u81ea\u5b9a\u4e49\u6765\u63d0\u9ad8\u7c7b\u7684\u53ef\u7528\u6027\u548c\u53ef\u8bfb\u6027\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u91cd\u8f7d\u52a0\u6cd5\u8fd0\u7b97\u7b26 <code>+<\/code> \u6765\u5b9e\u73b0\u4e24\u4e2a\u5bf9\u8c61\u7684\u76f8\u52a0\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<ol start=\"4\">\n<li>\u4f7f\u7528\u77ed\u8def\u8fd0\u7b97\u63d0\u9ad8\u6548\u7387<\/li>\n<\/ol>\n<p><p>\u5728\u903b\u8f91\u8868\u8fbe\u5f0f\u4e2d\uff0c\u53ef\u4ee5\u5229\u7528\u77ed\u8def\u8fd0\u7b97\u6765\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\u3002\u4f8b\u5982\uff0c\u5bf9\u4e8e\u8868\u8fbe\u5f0f <code>a and b<\/code>\uff0c\u5982\u679c <code>a<\/code> \u4e3a <code>False<\/code>\uff0c\u5219\u6574\u4e2a\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u4e00\u5b9a\u4e3a <code>False<\/code>\uff0c\u6b64\u65f6\u4e0d\u4f1a\u518d\u8ba1\u7b97 <code>b<\/code> \u7684\u503c\u3002<\/p>\n<\/p>\n<ol start=\"5\">\n<li>\u67e5\u9605\u5b98\u65b9\u6587\u6863\u4e86\u89e3\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u548c\u7ed3\u5408\u6027<\/li>\n<\/ol>\n<p><p>\u5728\u7f16\u5199\u4ee3\u7801\u65f6\uff0c\u53ef\u4ee5\u67e5\u9605Python\u7684\u5b98\u65b9\u6587\u6863\uff0c\u4e86\u89e3\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u548c\u7ed3\u5408\u6027\uff0c\u4ee5\u786e\u4fdd\u4ee3\u7801\u7684\u6b63\u786e\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<p><h3>\u7ed3\u8bba<\/h3>\n<\/p>\n<p><p>Python\u8bc6\u522b\u8fd0\u7b97\u7b26\u7684\u65b9\u5f0f\u662f\u901a\u8fc7\u89e3\u91ca\u5668\u89e3\u6790\u4ee3\u7801\u3001\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u3001\u8fd0\u7b97\u7b26\u91cd\u8f7d\u3001\u8fd0\u7b97\u7b26\u51fd\u6570\u5b9e\u73b0\u3002\u89e3\u91ca\u5668\u5728\u89e3\u6790\u4ee3\u7801\u65f6\uff0c\u901a\u8fc7\u8bcd\u6cd5\u5206\u6790\u548c\u8bed\u6cd5\u5206\u6790\u6765\u8bc6\u522b\u8fd0\u7b97\u7b26\uff0c\u5e76\u6839\u636e\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u548c\u7ed3\u5408\u6027\u6765\u51b3\u5b9a\u8fd0\u7b97\u987a\u5e8f\u3002\u8fd0\u7b97\u7b26\u91cd\u8f7d\u548c\u81ea\u5b9a\u4e49\u4f7f\u5f97\u81ea\u5b9a\u4e49\u7684\u7c7b\u53ef\u4ee5\u50cf\u5185\u7f6e\u7c7b\u578b\u4e00\u6837\u4f7f\u7528\u8fd0\u7b97\u7b26\u3002\u4e86\u89e3\u8fd0\u7b97\u7b26\u7684\u4f18\u5148\u7ea7\u548c\u7ed3\u5408\u6027\u3001\u5408\u7406\u4f7f\u7528\u77ed\u8def\u8fd0\u7b97\u548c\u8fd0\u7b97\u7b26\u91cd\u8f7d\uff0c\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u6b63\u786e\u6027\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>Python\u4e2d\u7684\u8fd0\u7b97\u7b26\u662f\u5982\u4f55\u5de5\u4f5c\u7684\uff1f<\/strong><br \/>Python\u4f7f\u7528\u4e00\u79cd\u79f0\u4e3a\u201c\u8fd0\u7b97\u7b26\u91cd\u8f7d\u201d\u7684\u673a\u5236\u6765\u8bc6\u522b\u548c\u5904\u7406\u8fd0\u7b97\u7b26\u3002\u6bcf\u4e2a\u8fd0\u7b97\u7b26\u5728Python\u4e2d\u90fd\u6709\u7279\u5b9a\u7684\u5185\u7f6e\u529f\u80fd\uff0c\u6bd4\u5982\u52a0\u6cd5\u8fd0\u7b97\u7b26\u201c+\u201d\u53ef\u4ee5\u7528\u4e8e\u6570\u5b57\u76f8\u52a0\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u5b57\u7b26\u4e32\u7684\u8fde\u63a5\u3002Python\u6839\u636e\u64cd\u4f5c\u6570\u7684\u7c7b\u578b\u6765\u51b3\u5b9a\u8be5\u4f7f\u7528\u54ea\u4e2a\u91cd\u8f7d\u7248\u672c\u7684\u8fd0\u7b97\u7b26\u3002<\/p>\n<p><strong>Python\u652f\u6301\u54ea\u4e9b\u7c7b\u578b\u7684\u8fd0\u7b97\u7b26\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u7c7b\u578b\u7684\u8fd0\u7b97\u7b26\uff0c\u5305\u62ec\u7b97\u672f\u8fd0\u7b97\u7b26\uff08\u5982\u52a0\u3001\u51cf\u3001\u4e58\u3001\u9664\uff09\u3001\u6bd4\u8f83\u8fd0\u7b97\u7b26\uff08\u5982\u7b49\u4e8e\u3001\u4e0d\u7b49\u4e8e\u3001\u5927\u4e8e\u3001\u5c0f\u4e8e\uff09\u3001\u903b\u8f91\u8fd0\u7b97\u7b26\uff08\u5982\u4e0e\u3001\u6216\u3001\u975e\uff09\u4ee5\u53ca\u4f4d\u8fd0\u7b97\u7b26\uff08\u5982\u4e0e\u3001\u6216\u3001\u5f02\u6216\uff09\u3002\u8fd9\u4e9b\u8fd0\u7b97\u7b26\u53ef\u4ee5\u7528\u4e8e\u4e0d\u540c\u6570\u636e\u7c7b\u578b\uff0c\u5982\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u5b57\u7b26\u4e32\u548c\u5e03\u5c14\u503c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u81ea\u5b9a\u4e49\u8fd0\u7b97\u7b26\u884c\u4e3a\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u901a\u8fc7\u5b9a\u4e49\u7c7b\u4e2d\u7684\u7279\u6b8a\u65b9\u6cd5\uff08\u5982<code>__add__<\/code>\u3001<code>__sub__<\/code>\u7b49\uff09\u6765\u91cd\u8f7d\u8fd0\u7b97\u7b26\u3002\u8fd9\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u4e3a\u81ea\u5b9a\u4e49\u5bf9\u8c61\u5b9a\u4e49\u7279\u5b9a\u7684\u8fd0\u7b97\u7b26\u884c\u4e3a\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u521b\u5efa\u4e86\u4e00\u4e2a\u8868\u793a\u590d\u6570\u7684\u7c7b\uff0c\u53ef\u4ee5\u91cd\u8f7d\u52a0\u6cd5\u8fd0\u7b97\u7b26\u4ee5\u4fbf\u4e8e\u4e24\u4e2a\u590d\u6570\u5bf9\u8c61\u7684\u76f8\u52a0\u3002<\/p>\n<p><strong>\u4f7f\u7528\u8fd0\u7b97\u7b26\u65f6\u53ef\u80fd\u9047\u5230\u54ea\u4e9b\u5e38\u89c1\u9519\u8bef\uff1f<\/strong><br \/>\u4f7f\u7528Python\u8fd0\u7b97\u7b26\u65f6\uff0c\u5e38\u89c1\u9519\u8bef\u5305\u62ec\u7c7b\u578b\u4e0d\u5339\u914d\uff0c\u4f8b\u5982\u5c1d\u8bd5\u5c06\u5b57\u7b26\u4e32\u4e0e\u6574\u6570\u76f8\u52a0\uff0c\u6216\u8005\u5728\u4e0d\u652f\u6301\u7684\u7c7b\u578b\u4e0a\u4f7f\u7528\u67d0\u4e2a\u8fd0\u7b97\u7b26\u3002\u8c03\u8bd5\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528<code>type()<\/code>\u51fd\u6570\u68c0\u67e5\u53d8\u91cf\u7684\u7c7b\u578b\uff0c\u786e\u4fdd\u64cd\u4f5c\u6570\u7684\u7c7b\u578b\u4e0e\u8fd0\u7b97\u7b26\u517c\u5bb9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u8bc6\u522b\u8fd0\u7b97\u7b26\u7684\u65b9\u5f0f\u662f\u901a\u8fc7\u89e3\u91ca\u5668\u89e3\u6790\u4ee3\u7801\u3001\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7\u3001\u8fd0\u7b97\u7b26\u91cd\u8f7d\u3001\u8fd0\u7b97\u7b26\u51fd\u6570\u5b9e\u73b0\u3002 \u5176\u4e2d\uff0c\u89e3\u91ca\u5668\u89e3\u6790 [&hellip;]","protected":false},"author":3,"featured_media":1066488,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1066479"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1066479"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1066479\/revisions"}],"predecessor-version":[{"id":1066489,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1066479\/revisions\/1066489"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1066488"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1066479"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1066479"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1066479"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}