{"id":53,"date":"2026-08-04T20:34:07","date_gmt":"2026-08-04T12:34:07","guid":{"rendered":"https:\/\/ltrainyard.icu\/?p=53"},"modified":"2026-08-06T00:41:04","modified_gmt":"2026-08-05T16:41:04","slug":"day-1-python-%e5%85%a5%e9%97%a8%ef%bc%9a%e4%bb%80%e4%b9%88%e6%98%af-python-%e4%b8%8e%e7%ac%ac%e4%b8%80%e4%b8%aa%e7%a8%8b%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/ltrainyard.icu\/index.php\/2026\/08\/04\/day-1-python-%e5%85%a5%e9%97%a8%ef%bc%9a%e4%bb%80%e4%b9%88%e6%98%af-python-%e4%b8%8e%e7%ac%ac%e4%b8%80%e4%b8%aa%e7%a8%8b%e5%ba%8f\/","title":{"rendered":"| Day 1 | Python \u5165\u95e8\uff1a\u4ec0\u4e48\u662f Python \u4e0e\u7b2c\u4e00\u4e2a\u7a0b\u5e8f |"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1 \u4ec0\u4e48\u662fpython<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66\uff1f<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7a0b\u5e8f<\/strong>\uff08program\uff09\u5c31\u662f<strong>\u5199\u7ed9\u7535\u8111\u7684\u4e00\u7ec4\u6307\u4ee4<\/strong>\u2014\u2014\u544a\u8bc9\u7535\u8111\u5148\u505a\u4ec0\u4e48\u3001\u518d\u505a\u4ec0\u4e48\u3002<strong>Python<\/strong>\u662f\u5176\u4e2d\u4e00\u79cd\u300c\u7f16\u7a0b\u8bed\u8a00\u300d\uff0c\u5c31\u50cf\u82f1\u8bed\u3001\u4e2d\u6587\u662f\u4eba\u4e0e\u4eba\u4ea4\u6d41\u7684\u8bed\u8a00\u4e00\u6837\uff0cPython \u662f\u4eba\u548c\u7535\u8111\u4ea4\u6d41\u7684\u8bed\u8a00\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e3a\u4ec0\u4e48\u96f6\u57fa\u7840\u8981\u5148\u61c2\u8fd9\u4e2a\uff1f\u56e0\u4e3a\u5982\u679c\u4f60\u8fde\u300c\u4ee3\u7801\u662f\u600e\u4e48\u88ab\u6267\u884c\u7684\u300d\u90fd\u6ca1\u6982\u5ff5\uff0c\u540e\u9762\u9047\u5230\u62a5\u9519\u4f1a\u5b8c\u5168\u61f5\u6389\u3002\u5148\u5efa\u7acb\u8fd9\u5e45\u5730\u56fe\uff0c\u4e4b\u540e\u6bcf\u4e00\u6b65\u90fd\u80fd\u77e5\u9053\u81ea\u5df1\u5728\u54ea\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7535\u8111\u672c\u8eab\u53ea\u8ba4\u8bc6\u4e00\u79cd\u8bed\u8a00\uff1a<strong>\u673a\u5668\u8bed\u8a00<\/strong>\uff08\u4e00\u4e32 0 \u548c 1\uff09\u3002\u4eba\u76f4\u63a5\u5199 0 \u548c 1 \u53c8\u6162\u53c8\u5bb9\u6613\u9519\uff0c\u6240\u4ee5\u4eba\u7c7b\u53d1\u660e\u4e86 Python \u8fd9\u79cd\u300c\u4eba\u7c7b\u53cb\u597d\u300d\u7684\u8bed\u8a00\u3002\u4f60\u5199\u7684 Python \u4ee3\u7801\u4f1a\u88ab\u4e00\u4e2a\u53eb<strong>\u89e3\u91ca\u5668<\/strong>\uff08interpreter\uff09\u7684\u7a0b\u5e8f\u9010\u884c\u7ffb\u8bd1\u6210\u7535\u8111\u80fd\u6267\u884c\u7684\u6307\u4ee4\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>\u89e3\u91ca\u5668<\/strong>\u5c31\u662f\u4e00\u4e2a\u300c\u7ffb\u8bd1\u5b98\u300d\uff0c\u5b83\u5750\u5728\u4f60\u7684\u4ee3\u7801\u548c\u7535\u8111\u4e4b\u95f4\uff0c\u628a Python \u4ee3\u7801\u4e00\u53e5\u4e00\u53e5\u7ffb\u8bd1\u7ed9\u7535\u8111\u542c\u3002<\/p>\n<\/blockquote>\n\n\n\n<pre class=\"wp-block-code\"><code># \u6211\u7684\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff1ahello.py\nprint(\"\u4f60\u597d\uff0c\u4e16\u754c\uff01\")     # \u2460 \u8ba9\u7a0b\u5e8f\u5f00\u53e3\u8bf4\u8bdd\nprint(\"\u6211\u5728\u5b66 Python\")    # \u2461 \u518d\u8bf4\u7b2c\u4e8c\u53e5\u8bdd\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd0\u884c\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u4f60\u597d\uff0c\u4e16\u754c\uff01\n\u6211\u5728\u5b66 Python\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u9010\u884c\u8bb2\u89e3\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7b2c 1 \u884c\uff1a<code>#<\/code> \u5f00\u5934\u662f<strong>\u6ce8\u91ca<\/strong>\uff0c\u5199\u7ed9\u4eba\u7c7b\u770b\u7684\uff0c\u7535\u8111\u5b8c\u5168\u5ffd\u7565\u3002<\/li>\n\n\n\n<li>\u7b2c 2 \u884c\uff1a<code>print(...)<\/code> \u8ba9\u7a0b\u5e8f\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u5185\u5bb9\uff0c\u62ec\u53f7\u91cc\u662f\u300c\u8981\u663e\u793a\u7684\u8bdd\u300d\u3002<\/li>\n\n\n\n<li>\u7b2c 3 \u884c\uff1a\u548c\u4e0a\u4e00\u884c\u4e00\u6837\uff0c\u7a0b\u5e8f\u4f1a<strong>\u4ece\u4e0a\u5f80\u4e0b<\/strong>\u4f9d\u6b21\u6267\u884c\u6bcf\u4e00\u884c\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u628a\u4ee3\u7801\u968f\u4fbf\u5199\u5728\u8bb0\u4e8b\u672c\u91cc\uff0c\u6269\u5c55\u540d\u5b58\u6210 <code>.txt<\/code> \u2192 \u95ee\u9898\uff1a\u89e3\u91ca\u5668\u627e\u4e0d\u5230\u3001\u8fd0\u884c\u4e0d\u4e86 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u6587\u4ef6\u540d\u5fc5\u987b\u4ee5 <code>.py<\/code> \u7ed3\u5c3e\uff0c\u5982 <code>hello.py<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u53ea\u5199\u4e00\u884c\u4ee3\u7801\u5c31\u53bb\u8fd0\u884c \u2192 \u95ee\u9898\uff1a\u4f53\u4f1a\u4e0d\u5230\u7a0b\u5e8f\u300c\u6309\u987a\u5e8f\u6267\u884c\u300d\u7684\u7279\u70b9 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u81f3\u5c11\u5199\u4e24\u4e09\u884c\u518d\u8fd0\u884c\uff0c\u611f\u53d7\u4ece\u4e0a\u5230\u4e0b\u7684\u6267\u884c\u987a\u5e8f\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u4ee5\u4e3a\u62a5\u9519\u662f\u7535\u8111\u300c\u574f\u4e86\u300d \u2192 \u95ee\u9898\uff1a\u4e0d\u6562\u52a8\u624b \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u62a5\u9519\u662f\u5e38\u6001\uff0cPython \u4f1a\u544a\u8bc9\u4f60\u9519\u5728\u54ea\u4e00\u884c\uff0c\u7167\u7740\u63d0\u793a\u6539\u5c31\u884c\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1a\u7a0b\u5e8f\u662f\u6307\u4ee4\uff0cPython \u662f\u8bed\u8a00\uff0c\u89e3\u91ca\u5668\u662f\u7ffb\u8bd1\u5b98\uff0c\u4ece\u4e0a\u5f80\u4e0b\u7167\u7740\u5e72\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2 print()<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>print()<\/code> \u662f Python \u5185\u7f6e\u7684<strong>\u8f93\u51fa\u51fd\u6570<\/strong>\uff0c\u4f5c\u7528\u662f\u300c\u628a\u5185\u5bb9\u663e\u793a\u5230\u5c4f\u5e55\u4e0a\u300d\u3002\u5b83\u662f\u4f60\u5b66\u7684\u7b2c\u4e00\u4e2a\u300c\u52a8\u4f5c\u300d\uff0c\u4e5f\u662f\u4e4b\u540e\u8c03\u8bd5\u7a0b\u5e8f\u7684\u5fc5\u5907\u6280\u80fd\u2014\u2014\u7a0b\u5e8f\u51fa\u95ee\u9898\u65f6\uff0c\u7528 <code>print()<\/code> \u6253\u5370\u4e2d\u95f4\u7ed3\u679c\uff0c\u5c31\u80fd\u770b\u5230\u7a0b\u5e8f\u5185\u90e8\u53d1\u751f\u4e86\u4ec0\u4e48\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>print()<\/code> \u672c\u8d28\u662f\u628a\u62ec\u53f7\u91cc\u7684\u5185\u5bb9\u9001\u5230\u4e00\u4e2a\u53eb<strong>\u6807\u51c6\u8f93\u51fa<\/strong>\uff08standard output\uff09\u7684\u5730\u65b9\u2014\u2014\u901a\u5e38\u5c31\u662f\u4f60\u7684\u7ec8\u7aef\u7a97\u53e3\u3002<code>print<\/code> \u540e\u9762\u90a3\u5bf9\u62ec\u53f7\u662f\u300c\u8c03\u7528\u51fd\u6570\u300d\u7684\u6807\u5fd7\uff1a<code>print<\/code> \u662f\u51fd\u6570\u540d\uff0c\u62ec\u53f7\u91cc\u662f<strong>\u53c2\u6570<\/strong>\uff08\u8981\u6253\u5370\u7684\u5185\u5bb9\uff09\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>\u51fd\u6570<\/strong>\uff08function\uff09\u5c31\u662f\u300c\u4e00\u6bb5\u63d0\u524d\u5199\u597d\u7684\u3001\u6709\u540d\u5b57\u7684\u4ee3\u7801\u300d\uff0c\u4f60\u558a\u5b83\u7684\u540d\u5b57\u5b83\u5c31\u53bb\u5e72\u6d3b\u3002<strong>\u53c2\u6570<\/strong>\uff08argument\uff09\u5c31\u662f\u300c\u9012\u7ed9\u51fd\u6570\u7684\u6750\u6599\u300d\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u751f\u6d3b\u7c7b\u6bd4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>print()<\/code> \u5c31\u50cf<strong>\u5bf9\u7740\u5bf9\u8bb2\u673a\u558a\u8bdd<\/strong>\uff1a\u4f60\u6309\u4e0b\u6309\u94ae\uff08\u8fd0\u884c\u5230\u8fd9\u884c\u4ee3\u7801\uff09\uff0c\u8bf4\u7684\u8bdd\uff08\u62ec\u53f7\u91cc\u7684\u5185\u5bb9\uff09\u5c31\u4f1a\u4f20\u5230\u5587\u53ed\uff08\u5c4f\u5e55\uff09\u4e0a\u88ab\u5927\u5bb6\u542c\u5230\u3002\u558a\u51e0\u53e5\u8bdd\uff0c\u5587\u53ed\u5c31\u64ad\u51e0\u53e5\u8bdd\uff0c\u987a\u5e8f\u5c31\u662f\u4f60\u558a\u7684\u987a\u5e8f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u610f\u4e8b\u9879\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1 <strong>\u5f15\u53f7<\/strong>\uff1a\u6253\u5370\u6587\u5b57\u548c\u6570\u5b57\u65f6 <strong>\u5f15\u53f7\u53ea\u5c5e\u4e8e\u300c\u5b57\u7b26\u4e32\u300d\u8fd9\u79cd\u7c7b\u578b<\/strong>\uff0c\u6570\u5b57\u4e0d\u9700\u8981\u5f15\u53f7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2 <strong>\u9017\u53f7<\/strong>\uff1a<strong>\u9017\u53f7\u628a\u591a\u4e2a\u5185\u5bb9\u5206\u5f00<\/strong>\uff0cPython \u4f1a\u5728\u6bcf\u4e2a\u5185\u5bb9\u4e4b\u95f4<strong>\u81ea\u52a8\u52a0\u4e00\u4e2a\u7a7a\u683c<\/strong>\u518d\u6253\u5370\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3 <strong>\u5355\u5f15\u53f7\u3001\u53cc\u5f15\u53f7<\/strong>\uff1a\u5355\u5f15\u53f7\u3001\u53cc\u5f15\u53f7\u90fd\u80fd\u5305\u5b57\u7b26\u4e32\uff0c\u4f46\u4e0d\u80fd\u300c\u5355\u5f15\u53f7\u5f00\u5934\u3001\u53cc\u5f15\u53f7\u7ed3\u5c3e\u300d\u6df7\u7740\u7528<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4 <strong>\u8f6c\u4e49\u5b57\u7b26<\/strong>\uff1a<code>\\n<\/code> \u548c <code>\\t<\/code> \u90fd\u662f<strong>\u8f6c\u4e49\u5b57\u7b26<\/strong>\u2014\u2014\u4ee5\u53cd\u659c\u6760 <code>\\<\/code> \u5f00\u5934\u3001\u6709\u7279\u6b8a\u542b\u4e49\u7684\u5b57\u7b26\u7ec4\u5408\u3002\u8f6c\u4e49\u5b57\u7b26\u867d\u7136\u5199\u5728\u5f15\u53f7\u91cc\uff0c\u4f46\u8f93\u51fa\u65f6\u4e0d\u4f1a\u663e\u793a\u6210 <code>\\n<\/code> \u8fd9\u4e24\u4e2a\u5b57\u7b26\uff0c\u800c\u662f\u771f\u7684\u6362\u884c\u3001\u8df3\u683c\u3002 \\n \u6362\u884c\uff08newline\uff09\uff0c\\t \u5236\u8868\u7b26\uff08Tab\uff09\u8868\u793a\u8df3\u4e00\u4e2a Tab \u4f4d<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>\u8f6c\u4e49\u5b57\u7b26<\/strong>\uff08escape character\uff09\u5c31\u662f\u300c\u62ab\u7740\u666e\u901a\u5916\u8863\u3001\u5e72\u7740\u7279\u6b8a\u4e8b\u300d\u7684\u5b57\u7b26\u7ec4\u5408\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(\"\u4f60\u597d) <\/code> \u2192 \u95ee\u9898\uff1a\u5f15\u53f7\u6ca1\u6210\u5bf9\uff0c\u62a5 <code>SyntaxError<\/code>\uff08\u8bed\u6cd5\u9519\u8bef\uff09 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>print(\"\u4f60\u597d\")<\/code>\uff0c\u5f15\u53f7\u5fc5\u987b\u914d\u5bf9\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(hello)<\/code> \u60f3\u6253\u5370 hello \u8fd9\u4e2a\u8bcd \u2192 \u95ee\u9898\uff1aPython \u4ee5\u4e3a hello \u662f\u53d8\u91cf\uff0c\u62a5 <code>NameError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>print(\"hello\")<\/code>\uff0c\u6587\u672c\u5fc5\u987b\u52a0\u5f15\u53f7\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(\"\u4ed6\u8bf4\uff1a\"\u4f60\u597d\"\")<\/code> \u2192 \u95ee\u9898\uff1a\u5f15\u53f7\u5d4c\u5957\u5bfc\u81f4\u8bed\u6cd5\u9519\u8bef \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5916\u5c42\u7528\u5355\u5f15\u53f7\uff1a<code>print('\u4ed6\u8bf4\uff1a\"\u4f60\u597d\"')<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(\"5\")<\/code> \u5374\u60f3\u62ff\u5b83\u505a\u8ba1\u7b97 \u2192 \u95ee\u9898\uff1a<code>\"5\"<\/code> \u662f\u6587\u672c\u4e0d\u662f\u6570\u5b57\uff0c\u4e0d\u80fd\u53c2\u4e0e\u6570\u5b66\u8fd0\u7b97 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>print(5)<\/code> \u4e0d\u5e26\u5f15\u53f7\u624d\u662f\u6570\u5b57\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1aprint \u5e26\u62ec\u53f7\uff0c\u5185\u5bb9\u5f80\u91cc\u653e\uff1b\u6587\u672c\u8981\u5f15\u53f7\uff0c\u6570\u5b57\u4e0d\u7528\u88c5\uff1b\u9017\u53f7\u5206\u5f00\u6253\uff0c\u7a7a\u683c\u81ea\u52a8\u52a0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3 \u6ce8\u91ca<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u91ca<\/strong>\uff08comment\uff09\u662f\u4ee5 <code>#<\/code> \u5f00\u5934\u7684\u8bf4\u660e\u6587\u5b57\uff0c<strong>\u7535\u8111\u4e0d\u4f1a\u6267\u884c\u5b83<\/strong>\uff0c\u7eaf\u7cb9\u5199\u7ed9\u4eba\u7c7b\u770b\u3002\u4e3a\u4ec0\u4e48\u5b66\uff1f\u56e0\u4e3a\u4ee3\u7801\u65e2\u662f\u5199\u7ed9\u7535\u8111\u7684\uff0c\u4e5f\u662f\u5199\u7ed9\u4eba\u7684\u2014\u2014\u4e09\u4e2a\u6708\u540e\u7684\u4f60\uff08\u4ee5\u53ca\u4f60\u7684\u961f\u53cb\uff09\u8981\u9760\u6ce8\u91ca\u5feb\u901f\u770b\u61c2\u4ee3\u7801\u5728\u5e72\u561b\u3002\u4f1a\u5199\u6ce8\u91ca\uff0c\u662f\u4ece\u300c\u80fd\u8dd1\u7684\u4ee3\u7801\u300d\u8d70\u5411\u300c\u597d\u4ee3\u7801\u300d\u7684\u7b2c\u4e00\u6b65\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u89e3\u91ca\u5668\u8bfb\u5230 <code>#<\/code> \u65f6\uff0c\u4f1a\u8df3\u8fc7\u8fd9\u4e00\u884c\u4e2d <code>#<\/code> \u4e4b\u540e\u7684\u6240\u6709\u5185\u5bb9\uff0c\u76f4\u63a5\u770b\u4e0b\u4e00\u884c\u3002\u6240\u4ee5\u6ce8\u91ca\u60f3\u5199\u591a\u957f\u3001\u5199\u4ec0\u4e48\u90fd\u53ef\u4ee5\uff0c\u5b8c\u5168\u4e0d\u5f71\u54cd\u7a0b\u5e8f\u8fd0\u884c\u3002\u6ce8\u91ca\u4e0d\u662f\u300c\u529f\u80fd\u300d\uff0c\u800c\u662f\u300c\u8bf4\u660e\u4e66\u300d\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u751f\u6d3b\u7c7b\u6bd4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u91ca\u5c31\u50cf<strong>\u8bfe\u672c\u4e0a\u7684\u6279\u6ce8<\/strong>\uff1a\u6b63\u6587\uff08\u4ee3\u7801\uff09\u662f\u8981\u8003\u6838\u7684\u5185\u5bb9\uff0c\u6279\u6ce8\uff08\u6ce8\u91ca\uff09\u662f\u4f60\u5199\u6765\u5e2e\u52a9\u81ea\u5df1\u7406\u89e3\u7684\u3002\u8003\u8bd5\uff08\u8fd0\u884c\u7a0b\u5e8f\uff09\u53ea\u770b\u6b63\u6587\uff0c\u6279\u6ce8\u4e0d\u4f1a\u989d\u5916\u52a0\u5206\uff1b\u4f46\u6ca1\u6709\u6279\u6ce8\uff0c\u590d\u4e60\uff08\u8bfb\u4ee3\u7801\uff09\u65f6\u4f60\u4f1a\u6293\u72c2\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5982\u4f55\u6ce8\u91ca<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5355\u884c\u6ce8\u91ca\u7528<code>#<\/code> \u591a\u884c\u6ce8\u91ca\u7528<code>\"\"\"<\/code>(\u4e09\u5f15\u53f7)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u628a\u6ce8\u91ca\u5199\u5728\u5f15\u53f7\u91cc\u9762\uff1a<code>print(\"# \u8fd9\u4e0d\u662f\u6ce8\u91ca\")<\/code> \u2192 \u95ee\u9898\uff1a<code>#<\/code> \u5728\u5b57\u7b26\u4e32\u91cc\u5c31\u662f\u666e\u901a\u5b57\u7b26\uff0c\u4f1a\u88ab\u539f\u6837\u6253\u5370\u51fa\u6765 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>#<\/code> \u5fc5\u987b\u5199\u5728\u5f15\u53f7\u5916\u9762\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u6ce8\u91ca\u548c\u4ee3\u7801\u6324\u5728\u4e00\u884c\u4e14 <code>#<\/code> \u524d\u6ca1\u6709\u7a7a\u683c\uff1a<code>print(\"hi\")#\u6ce8\u91ca<\/code> \u2192 \u95ee\u9898\uff1a\u80fd\u8fd0\u884c\uff0c\u4f46\u53ef\u8bfb\u6027\u5dee \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>print(\"hi\")  # \u6ce8\u91ca<\/code>\uff0c<code>#<\/code> \u524d\u81f3\u5c11\u7559\u4e00\u4e2a\u7a7a\u683c\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u6574\u4e2a\u6587\u4ef6\u4e0d\u5199\u4efb\u4f55\u6ce8\u91ca \u2192 \u95ee\u9898\uff1a\u4e00\u4e2a\u6708\u540e\u81ea\u5df1\u90fd\u770b\u4e0d\u61c2 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5173\u952e\u6b65\u9aa4\u3001\u96be\u61c2\u7684\u5730\u65b9\u968f\u624b\u52a0\u6ce8\u91ca\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1a\u4e95\u53f7\u5f00\u5934\u662f\u6ce8\u91ca\uff0c\u673a\u5668\u8df3\u8fc7\u4f60\u522b\u5fd8\uff1b\u5199\u7ed9\u672a\u6765\u7684\u81ea\u5df1\uff0c\u5173\u952e\u5730\u65b9\u7559\u4e00\u884c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4 \u53d8\u91cf<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8fd9\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u53d8\u91cf<\/strong>\uff08variable\uff09\u5c31\u662f\u7ed9\u6570\u636e\u8d77\u7684\u300c\u540d\u5b57\u300d\u3002\u7a0b\u5e8f\u91cc\u6570\u636e\u5f88\u591a\uff0c\u6bcf\u6b21\u90fd\u5199\u4e00\u904d\u592a\u9ebb\u70e6\uff0c\u800c\u4e14\u540e\u9762\u8fd8\u8981\u53cd\u590d\u7528\u2014\u2014\u7ed9\u6570\u636e\u8d77\u4e2a\u540d\u5b57\uff0c\u4e4b\u540e\u558a\u540d\u5b57\u5c31\u80fd\u7528\u6570\u636e\u3002\u4e3a\u4ec0\u4e48\u96f6\u57fa\u7840\u5fc5\u5b66\uff1f\u56e0\u4e3a\u51e0\u4e4e\u6240\u6709\u7684\u7a0b\u5e8f\u90fd\u5728\u505a\u540c\u4e00\u4ef6\u4e8b\uff1a<strong>\u5b58\u6570\u636e \u2192 \u7b97\u6570\u636e \u2192 \u7528\u6570\u636e<\/strong>\uff0c\u53d8\u91cf\u5c31\u662f\u300c\u5b58\u6570\u636e\u300d\u7684\u57fa\u7840\u8bbe\u65bd\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u4f60\u5199 <code>age = 18<\/code> \u65f6\uff0cPython \u5728<strong>\u5185\u5b58<\/strong>\uff08\u7535\u8111\u7684\u4e34\u65f6\u4ed3\u5e93\uff09\u91cc\u627e\u4e00\u5757\u5730\u65b9\u5b58\u4e0b <code>18<\/code>\uff0c\u7136\u540e\u8ba9\u540d\u5b57 <code>age<\/code> \u6307\u5411\u5b83\u3002\u4e4b\u540e\u4f60\u5199 <code>age<\/code>\uff0cPython \u5c31\u53bb\u5185\u5b58\u91cc\u627e <code>18<\/code> \u6765\u7528\u3002\u53d8\u91cf\u53ef\u4ee5\u91cd\u65b0\u8d4b\u503c\uff1a<code>age = 19<\/code> \u4e4b\u540e\uff0c<code>age<\/code> \u5c31\u6307\u5411\u65b0\u7684 <code>19<\/code>\uff0c\u65e7\u6570\u636e\u88ab\u300c\u66ff\u6362\u300d\u6389\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>\u5185\u5b58<\/strong>\uff08memory\uff09\u662f\u7535\u8111\u8fd0\u884c\u65f6\u4e34\u65f6\u5b58\u653e\u6570\u636e\u7684\u5730\u65b9\uff0c\u7a0b\u5e8f\u7ed3\u675f\u540e\u6570\u636e\u5c31\u6e05\u7a7a\u4e86\uff08\u6240\u4ee5\u7a0b\u5e8f\u91cd\u542f\u540e\u53d8\u91cf\u4f1a\u300c\u5931\u5fc6\u300d\uff09\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u751f\u6d3b\u7c7b\u6bd4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u53d8\u91cf\u50cf<strong>\u5bbf\u820d\u697c\u7684\u50a8\u7269\u67dc<\/strong>\uff1a\u6bcf\u4e2a\u67dc\u5b50\u6709\u7f16\u53f7\uff08\u53d8\u91cf\u540d\uff09\uff0c\u67dc\u5b50\u91cc\u653e\u7740\u4f60\u7684\u4e1c\u897f\uff08\u6570\u636e\uff09\u3002\u4f60\u8981\u62ff\u4e1c\u897f\u4e0d\u7528\u628a\u67dc\u5b50\u642c\u8d70\uff0c\u53ea\u9700\u8981\u62a5\u7f16\u53f7\u3002\u6362\u4e1c\u897f\uff08\u91cd\u65b0\u8d4b\u503c\uff09\u4e5f\u7b80\u5355\u2014\u2014\u6253\u5f00\u67dc\u5b50\uff0c\u628a\u65e7\u4e1c\u897f\u62ff\u51fa\u6765\u3001\u653e\u65b0\u4e1c\u897f\u8fdb\u53bb\uff0c\u7f16\u53f7\u4e0d\u53d8\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u610f\u4e8b\u9879\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1 <strong>\u5b9a\u4e49\u53d8\u91cf\u5e76\u6253\u5370<\/strong>: <code>age = 18 <\/code>\u672f\u8bed\u53eb <strong>\u8d4b\u503c<\/strong> \u7528 <code>=<\/code> \u628a<code>=<\/code>\u53f3\u8fb9\u7684\u6570\u636e\u4ea4\u7ed9\u5de6\u8fb9\u7684\u540d\u5b57, <code>print(age)<\/code>\u300c\u558a\u540d\u5b57\u62ff\u6570\u636e\u300d\uff0cprint \u6253\u5370\u7684\u662f<strong>\u53d8\u91cf\u91cc\u5b58\u7684\u503c<\/strong>\uff0c\u4e0d\u662f\u53d8\u91cf\u540d\u672c\u8eab\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2 <strong>\u53d8\u91cf\u53ef\u4ee5\u53c2\u4e0e\u8ba1\u7b97<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = 1 \nb = 2 \ntotal = a * b\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>total = a * b<\/code> \u8fd9\u884c\u4f1a\u5148\u7b97\u51fa <code>1 * 2 = 2<\/code>\uff0c\u518d\u628a\u7ed3\u679c <code>2<\/code> \u5b58\u8fdb <code>total<\/code>\u3002\u8d4b\u503c <code>=<\/code> \u7684\u89c4\u5219\u662f\uff1a<strong>\u5148\u7b97\u53f3\u8fb9\uff0c\u518d\u5b58\u5de6\u8fb9<\/strong>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3 <strong>\u53d8\u91cf\u53ef\u4ee5\u91cd\u65b0\u8d4b\u503c<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>a = 1\nprint(a)\na = 2\nprint(a)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>a = 2<\/code> \u628a\u65e7\u503c 1 \u8986\u76d6\u6389\uff0c\u6b64\u540e <code>a<\/code> \u4ee3\u8868\u7684\u5c31\u662f 2\u3002\u6ce8\u610f\u6253\u5370\u65f6<strong>\u4e0d\u5e26\u5f15\u53f7<\/strong>\u2014\u2014\u5982\u679c\u5199 <code>print(\"a\")<\/code>\uff0c\u6253\u5370\u51fa\u6765\u7684\u662f\u5b57\u6bcd a \u672c\u8eab\uff0c\u800c\u4e0d\u662f\u5b83\u7684\u503c\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">4 <strong>\u53d8\u91cf\u5408\u6cd5\u4e0e\u4e0d\u5408\u6cd5<\/strong>:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5408\u6cd5\u53d8\u91cf<\/strong>\n1.\u53ea\u80fd\u7531\u5b57\u6bcd\uff08a-z A-Z\uff09\u3001\u6570\u5b57\uff080-9\uff09\u3001\u4e0b\u5212\u7ebf\uff08_\uff09\u7ec4\u6210\n2.\u4e0d\u80fd\u4ee5\u6570\u5b57\u5f00\u5934\n3.\u4e0d\u80fd\u662f Python \u5173\u952e\u5b57\n4.\u533a\u5206\u5927\u5c0f\u5199\uff08Age \u548c age \u662f\u4e24\u4e2a\u4e0d\u540c\u53d8\u91cf\uff09<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4e0d\u5408\u6cd5\u53d8\u91cf<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1var = 5        # \u4ee5\u6570\u5b57\u5f00\u5934 \u2192 SyntaxError: invalid decimal literal\nmy-var = 5      # \u8fde\u5b57\u7b26 - \u4e0d\u5141\u8bb8\nmy var = 5      # \u7a7a\u683c\u4e0d\u5141\u8bb8\nclass = 5       # class \u662f\u5173\u952e\u5b57\nif = 5          # if \u662f\u5173\u952e\u5b57\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>python\u5168\u90e8\u5173\u952e\u5b57<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>False  None  True  and  as  assert  async  await  break\nclass  continue  def  del  elif  else  except  finally  for\nfrom  global  if  import  in  is  lambda  nonlocal  not  or\npass  raise  return  try  while  with  yield\n\n\u8865\u5145\uff1amatch\u3001case \u662f 3.10+ \u7684\u8f6f\u5173\u952e\u5b57\uff0c\u53ef\u4ee5\u5f53\u53d8\u91cf\u540d\u7528\uff08\u4f46\u5efa\u8bae\u4e5f\u522b\u7528\uff0c\u5bb9\u6613\u6df7\u6dc6\uff09\u3002\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5feb\u901f\u8bb0\u5fc6\u53e3\u8bc0<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5b57\u6bcd\u4e0b\u5212\u7ebf\u5f00\u5934\uff0c\u6570\u5b57\u4e0d\u80fd\u653e\u6700\u524d\uff1b\u4e2d\u95f4\u53ea\u80fd\u5b57\u6bcd\u6570\u7ebf\uff08\u6570\u5b57\/\u4e0b\u5212\u7ebf\uff09\uff0c\u5173\u952e\u5b57\u540d\u4e0d\u80fd\u5360\u3002\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>1name = \"\u5c0f\u660e\"<\/code> \u2192 \u95ee\u9898\uff1a\u6570\u5b57\u5f00\u5934\uff0c\u62a5 <code>SyntaxError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>name1 = \"\u5c0f\u660e\"<\/code>\uff0c\u540d\u5b57\u53ea\u80fd\u4ee5\u5b57\u6bcd\u6216\u4e0b\u5212\u7ebf\u5f00\u5934\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>my-name = \"\u5c0f\u660e\"<\/code> \u2192 \u95ee\u9898\uff1a\u51cf\u53f7\u88ab\u5f53\u6210\u8fd0\u7b97\u7b26\uff0c\u62a5\u8bed\u6cd5\u9519\u8bef \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>my_name = \"\u5c0f\u660e\"<\/code>\uff0c\u7528\u4e0b\u5212\u7ebf\u8fde\u63a5\u5355\u8bcd\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>if = 10<\/code> \u2192 \u95ee\u9898\uff1a<code>if<\/code> \u662f Python \u5173\u952e\u5b57\uff0c\u88ab\u7cfb\u7edf\u5360\u7528 \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u6362\u4e2a\u540d\u5b57\uff0c\u5982 <code>if_score = 10<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(score)<\/code> \u4f46\u524d\u9762\u4ece\u6ca1\u5b9a\u4e49\u8fc7 score \u2192 \u95ee\u9898\uff1a\u62a5 <code>NameError: name 'score' is not defined<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5148\u6267\u884c <code>score = 80<\/code> \u8d4b\u503c\uff0c\u518d\u6253\u5370\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1a\u53d8\u91cf\u50cf\u67dc\u5b50\uff0c\u540d\u5b57\u8d34\u6807\u7b7e\uff1b\u5148\u7b97\u53f3\u8fb9\u503c\uff0c\u518d\u5b58\u5de6\u8fb9\u540d\uff1b\u6253\u5370\u4e0d\u5e26\u5f15\u53f7\uff0c\u5426\u5219\u6253\u51fa\u7684\u662f\u540d\u5b57\u672c\u8eab\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5 \u5e03\u5c14\u7c7b\u578b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8fd9\u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e03\u5c14\u7c7b\u578b<\/strong>\uff08bool\uff09\u53ea\u6709\u4e24\u4e2a\u503c\uff1a<code>True<\/code>\uff08\u771f\uff09\u548c <code>False<\/code>\uff08\u5047\uff09\uff0c\u7528\u6765\u8868\u8fbe\u300c\u662f\/\u5426\u3001\u5bf9\/\u9519\u300d\u8fd9\u6837\u7684\u5224\u65ad\u7ed3\u679c\u3002\u4e3a\u4ec0\u4e48\u73b0\u5728\u5c31\u8981\u61c2\uff1f\u56e0\u4e3a\u7a0b\u5e8f\u91cc\u5230\u5904\u90fd\u5728\u505a\u5224\u65ad\u2014\u2014\u300c\u5e74\u9f84\u591f\u4e0d\u591f 18\u300d\u300c\u5206\u6570\u53ca\u4e0d\u53ca\u683c\u300d\uff0c\u8fd9\u4e9b\u5224\u65ad\u7684\u7ed3\u679c\u90fd\u662f\u5e03\u5c14\u503c\u3002\u5b83\u867d\u7136\u7b80\u5355\uff0c\u5374\u662f\u540e\u9762\u5b66 <code>if<\/code> \u6761\u4ef6\u5224\u65ad\u7684\u5730\u57fa\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u5e95\u5c42\u539f\u7406<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Python \u91cc\u7684 <code>True<\/code> \u548c <code>False<\/code> \u662f\u4e24\u4e2a\u7279\u6b8a\u503c\uff0c\u5206\u522b\u5bf9\u5e94\u300c\u771f\u300d\u548c\u300c\u5047\u300d\u3002\u7528 <code>bool()<\/code> \u53ef\u4ee5\u628a\u5176\u4ed6\u6570\u636e\u8f6c\u6210\u5e03\u5c14\u503c\uff1a\u6570\u5b57 <code>0<\/code> \u662f <code>False<\/code>\uff0c\u975e 0 \u662f <code>True<\/code>\uff1b\u7a7a\u5b57\u7b26\u4e32 <code>\"\"<\/code> \u662f <code>False<\/code>\uff0c\u975e\u7a7a\u662f <code>True<\/code>\u3002\u6bd4\u8f83\u8fd0\u7b97\uff08\u5982 <code>&gt;<\/code>\u3001<code>&lt;<\/code>\u3001<code>==<\/code>\uff09\u7684\u7ed3\u679c\u4e5f\u662f\u5e03\u5c14\u503c\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">\u672f\u8bed\u5c0f\u8bcd\u5178\uff1a<strong>\u6bd4\u8f83\u8fd0\u7b97<\/strong>\u5c31\u662f\u300c\u6bd4\u5927\u5c0f\u3001\u5224\u76f8\u7b49\u300d\uff0c\u7ed3\u679c\u53ea\u4f1a\u662f <code>True<\/code> \u6216 <code>False<\/code>\u3002<\/p>\n<\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u751f\u6d3b\u7c7b\u6bd4<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5e03\u5c14\u7c7b\u578b\u5c31\u50cf<strong>\u706f\u7684\u5f00\u5173<\/strong>\uff1a\u53ea\u6709\u5f00\uff08True\uff09\u548c\u5173\uff08False\uff09\u4e24\u79cd\u72b6\u6001\uff0c\u6ca1\u6709\u7b2c\u4e09\u79cd\u3002\u7a0b\u5e8f\u91cc\u9700\u8981\u300c\u662f\u6216\u5426\u300d\u7684\u65f6\u5019\uff0c\u5c31\u4f1a\u7528\u5230\u8fd9\u4e2a\u5f00\u5173\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6ce8\u610f\u4e8b\u9879\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1 <strong>\u5e03\u5c14\u503c\u53ea\u6709 True \u548c False<\/strong>:\u5e03\u5c14\u503c <code>True<\/code> \/ <code>False<\/code> \u9996\u5b57\u6bcd<strong>\u5fc5\u987b\u5927\u5199<\/strong>\uff0c\u4e0d\u80fd\u5199\u6210 <code>true<\/code> \u6216 <code>false<\/code>\uff0c\u5426\u5219 Python \u4f1a\u628a\u5b83\u5f53\u6210\u53d8\u91cf\u540d\uff0c\u62a5 <code>NameError<\/code>\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2 <strong>\u6bd4\u8f83\u8fd0\u7b97\u7684\u7ed3\u679c\u662f\u5e03\u5c14\u503c<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>age = 18\nprint(age &gt; 16)    # 18 \u5927\u4e8e 16\uff0c\u662f \u2192 True\nprint(age &lt; 16)    # 18 \u5c0f\u4e8e 16\uff0c\u5426 \u2192 False\nprint(age == 18)   # \u76f8\u7b49\u7528\u4e24\u4e2a\u7b49\u53f7 ==\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>&gt;<\/code> \u5927\u4e8e\u3001<code>&lt;<\/code> \u5c0f\u4e8e\u3001<code>==<\/code> \u5224\u65ad\u662f\u5426\u76f8\u7b49\uff0c\u7ed3\u679c\u90fd\u662f\u5e03\u5c14\u503c\u3002\u6ce8\u610f\u5224\u65ad\u76f8\u7b49\u662f**\u4e24\u4e2a\u7b49\u53f7 <code>==<\/code>**\uff0c\u4e00\u4e2a\u7b49\u53f7 <code>=<\/code> \u662f\u8d4b\u503c\uff0c\u4e24\u8005\u5343\u4e07\u522b\u6df7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3 <strong>\u7528 bool() \u628a\u5176\u4ed6\u6570\u636e\u8f6c\u6210\u5e03\u5c14\u503c<\/strong>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(bool(0))       # 0 \u2192 False\nprint(bool(1))       # \u975e 0 \u2192 True\nprint(bool(\"\"))      # \u7a7a\u5b57\u7b26\u4e32 \u2192 False\nprint(bool(\"\u4f60\u597d\"))  # \u975e\u7a7a\u5b57\u7b26\u4e32 \u2192 True\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f6c\u6362\u89c4\u5219\u4e00\u53e5\u8bdd\u8bb0\uff1a<strong>\u300c\u7a7a\u300d\u662f False\uff0c\u300c\u4e0d\u7a7a\u300d\u662f True<\/strong>\u3002\u6570\u5b57 0\u3001\u7a7a\u5b57\u7b26\u4e32\u7b49\u90fd\u662f False\uff0c\u5176\u4f59\u57fa\u672c\u90fd\u662f True\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6613\u9519\u70b9<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>is_student = true<\/code> \u2192 \u95ee\u9898\uff1a<code>true<\/code> \u9996\u5b57\u6bcd\u6ca1\u5927\u5199\uff0c\u88ab\u5f53\u6210\u53d8\u91cf\u540d\uff0c\u62a5 <code>NameError<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>is_student = True<\/code>\uff0c<code>True<\/code> \/ <code>False<\/code> \u9996\u5b57\u6bcd\u5fc5\u987b\u5927\u5199\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(age = 18)<\/code> \u60f3\u5224\u65ad age \u662f\u5426\u7b49\u4e8e 18 \u2192 \u95ee\u9898\uff1a<code>=<\/code> \u662f\u8d4b\u503c\u4e0d\u662f\u6bd4\u8f83\uff0c\u4f1a\u62a5\u8bed\u6cd5\u9519\u8bef \u2192 \u6b63\u786e\u5199\u6cd5\uff1a<code>print(age == 18)<\/code>\uff0c\u5224\u65ad\u76f8\u7b49\u7528\u4e24\u4e2a\u7b49\u53f7\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a<code>print(bool(\" \"))<\/code> \u4ee5\u4e3a\u7a7a\u683c\u662f False \u2192 \u95ee\u9898\uff1a\u7a7a\u683c\u7b97\u300c\u975e\u7a7a\u300d\uff0c\u7ed3\u679c\u662f <code>True<\/code> \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u53ea\u6709\u771f\u6b63\u7684\u7a7a\u5b57\u7b26\u4e32 <code>\"\"<\/code> \u624d\u662f <code>False<\/code>\u3002<\/li>\n\n\n\n<li>\u9519\u8bef\u5199\u6cd5\uff1a\u7528 1 \u548c 0 \u4ee3\u66ff True \u548c False \u2192 \u95ee\u9898\uff1a\u80fd\u8fd0\u884c\u4f46\u4e0d\u76f4\u89c2\uff0c\u53ef\u8bfb\u6027\u5dee \u2192 \u6b63\u786e\u5199\u6cd5\uff1a\u5224\u65ad\u7c7b\u53d8\u91cf\u76f4\u63a5\u7528 <code>True<\/code> \/ <code>False<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8bb0\u5fc6\u53e3\u8bc0<\/strong>\uff1a\u5e03\u5c14\u53ea\u6709\u4e24\u4e2a\u503c\uff0cTrue \u771f\u6765 False \u5047\uff1b\u9996\u5b57\u6bcd\u8981\u5927\u5199\uff0c\u6bd4\u8f83\u8fd0\u7b97\u51fa\u771f\u5047\uff1b\u5224\u65ad\u76f8\u7b49\u53cc\u7b49\u53f7\uff0c\u8d4b\u503c\u5355\u7b49\u522b\u641e\u6df7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u4eca\u65e5\u603b\u7ed3<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7a0b\u5e8f\u662f\u5199\u7ed9\u7535\u8111\u7684\u6307\u4ee4\uff0cPython \u662f\u7f16\u7a0b\u8bed\u8a00\uff0c\u89e3\u91ca\u5668\u8d1f\u8d23\u7ffb\u8bd1\u6267\u884c\n<code>print()<\/code> \u80fd\u6253\u5370\u6587\u5b57\u548c\u6570\u5b57\uff0c\u591a\u4e2a\u5185\u5bb9\u7528\u9017\u53f7\u5206\u9694\u4f1a\u81ea\u52a8\u52a0\u7a7a\u683c\n\u5b57\u7b26\u4e32\u5fc5\u987b\u52a0\u5f15\u53f7\u4e14\u6210\u5bf9\u51fa\u73b0\uff1b<code>\\n<\/code> \u6362\u884c\u3001<code>\\t<\/code> \u5236\u8868\u7b26\n\u6ce8\u91ca\u7528 <code>#<\/code> \u5f00\u5934\uff0c\u4e0d\u4f1a\u6267\u884c\uff0c\u662f\u5199\u7ed9\u672a\u6765\u81ea\u5df1\u770b\u7684\n\u53d8\u91cf = \u7ed9\u6570\u636e\u8d77\u540d\u5b57\uff0c\u547d\u540d\u8981\u89c4\u8303\uff08\u5b57\u6bcd\/\u6570\u5b57\/\u4e0b\u5212\u7ebf\uff0c\u4e0d\u80fd\u6570\u5b57\u5f00\u5934\uff09\n\u8d4b\u503c\u89c4\u5219\uff1a\u5148\u7b97\u53f3\u8fb9\uff0c\u518d\u5b58\u5de6\u8fb9\uff1b\u53d8\u91cf\u53ef\u4ee5\u968f\u65f6\u91cd\u65b0\u8d4b\u503c\n\u5e03\u5c14\u53ea\u6709\u4e24\u4e2a\u503c\uff0cTrue \u771f\u6765 False \u5047\uff1b\u9996\u5b57\u6bcd\u8981\u5927\u5199\n\u6bd4\u8f83\u8fd0\u7b97\u51fa\u771f\u5047\uff1b\u5224\u65ad\u76f8\u7b49\u53cc\u7b49\u53f7\uff0c\u8d4b\u503c\u5355\u7b49\u522b\u641e\u6df7\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u62a5\u9519<\/th><th>\u539f\u56e0<\/th><th>\u4fee\u590d<\/th><\/tr><\/thead><tbody><tr><td><code>SyntaxError<\/code><\/td><td>\u8bed\u6cd5\u9519\u8bef\uff0c\u62ec\u53f7\/\u5f15\u53f7\/\u7f29\u8fdb\u4e0d\u914d\u5bf9<\/td><td>\u68c0\u67e5\u914d\u5bf9<\/td><\/tr><tr><td><code>NameError<\/code><\/td><td>\u53d8\u91cf\u540d\u62fc\u5199\u9519\u8bef\u6216\u6ca1\u5b9a\u4e49<\/td><td>\u68c0\u67e5\u540d\u5b57<\/td><\/tr><tr><td><code>TypeError<\/code><\/td><td>\u7c7b\u578b\u4e0d\u5339\u914d\uff08Day 2 \u7ec6\u8bb2\uff09<\/td><td>\u5148\u4e86\u89e3\u5373\u53ef<\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>1 \u4ec0\u4e48\u662fpython \u662f\u4ec0\u4e48\uff1f\u4e3a\u4ec0\u4e48\u5b66\uff1f \u7a0b\u5e8f\uff08program\uff09\u5c31\u662f\u5199\u7ed9\u7535\u8111\u7684\u4e00\u7ec4\u6307\u4ee4\u2014\u2014\u544a\u8bc9\u7535\u8111\u5148\u505a\u4ec0\u4e48\u3001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[16,9],"tags":[],"class_list":["post-53","post","type-post","status-publish","format-standard","hentry","category-python","category-code-dev"],"_links":{"self":[{"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/posts\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":3,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":130,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/posts\/53\/revisions\/130"}],"wp:attachment":[{"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/media?parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/categories?post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ltrainyard.icu\/index.php\/wp-json\/wp\/v2\/tags?post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}