{"id":8721,"date":"2023-05-15T17:05:25","date_gmt":"2023-05-15T09:05:25","guid":{"rendered":"\/?p=8721"},"modified":"2023-05-15T17:05:25","modified_gmt":"2023-05-15T09:05:25","slug":"python%e5%85%b3%e9%94%ae%e5%ad%97%ef%bc%88%e4%bf%9d%e7%95%99%e5%ad%97%ef%bc%89%e4%b8%80%e8%a7%88%e8%a1%a8","status":"publish","type":"post","link":"\/?p=8721","title":{"rendered":"Python\u5173\u952e\u5b57\uff08\u4fdd\u7559\u5b57\uff09\u4e00\u89c8\u8868"},"content":{"rendered":"<p>\u4fdd\u7559\u5b57\u662f<strong>Python<\/strong> \u8bed\u8a00\u4e2d\u4e00\u4e9b\u5df2\u7ecf\u88ab\u8d4b\u4e88\u7279\u5b9a\u610f\u4e49\u7684\u5355\u8bcd\uff0c\u8fd9\u5c31\u8981\u6c42\u5f00\u53d1\u8005\u5728\u5f00\u53d1\u7a0b\u5e8f\u65f6\uff0c\u4e0d\u80fd\u7528\u8fd9\u4e9b\u4fdd\u7559\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u7ed9\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u3001\u6a21\u677f\u4ee5\u53ca\u5176\u4ed6\u5bf9\u8c61\u547d\u540d\u3002<\/p>\n<p>Python \u5305\u542b\u7684\u4fdd\u7559\u5b57\u53ef\u4ee5\u6267\u884c\u5982\u4e0b\u547d\u4ee4\u8fdb\u884c\u67e5\u770b\uff1a<\/p>\n<pre><code class=\"language-bash\">>&gt;&gt; import keyword\n>&gt;&gt; keyword.kwlist\n[&#039;False&#039;, &#039;None&#039;, &#039;True&#039;, &#039;and&#039;, &#039;as&#039;, &#039;assert&#039;, &#039;break&#039;, &#039;class&#039;, &#039;continue&#039;, &#039;def&#039;, &#039;del&#039;, &#039;elif&#039;, &#039;else&#039;, &#039;except&#039;, &#039;finally&#039;, &#039;for&#039;, &#039;from&#039;, &#039;global&#039;, &#039;if&#039;, &#039;import&#039;, &#039;in&#039;, &#039;is&#039;, &#039;lambda&#039;, &#039;nonlocal&#039;, &#039;not&#039;, &#039;or&#039;, &#039;pass&#039;, &#039;raise&#039;, &#039;return&#039;, &#039;try&#039;, &#039;while&#039;, &#039;with&#039;, &#039;yield&#039;]<\/code><\/pre>\n<p>\u6240\u6709\u7684\u4fdd\u7559\u5b57\uff0c\u5982\u4e0b\u8868\u6240\u793a\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>and<\/th>\n<th>as<\/th>\n<th>assert<\/th>\n<th>break<\/th>\n<th>class<\/th>\n<th>continue<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>def<\/td>\n<td>del<\/td>\n<td>elif<\/td>\n<td>else<\/td>\n<td>except<\/td>\n<td>finally<\/td>\n<\/tr>\n<tr>\n<td>for<\/td>\n<td>from<\/td>\n<td>False<\/td>\n<td>global<\/td>\n<td>if<\/td>\n<td>import<\/td>\n<\/tr>\n<tr>\n<td>in<\/td>\n<td>is<\/td>\n<td>lambda<\/td>\n<td>nonlocal<\/td>\n<td>not<\/td>\n<td>None<\/td>\n<\/tr>\n<tr>\n<td>or<\/td>\n<td>pass<\/td>\n<td>raise<\/td>\n<td>return<\/td>\n<td>try<\/td>\n<td>True<\/td>\n<\/tr>\n<tr>\n<td>while<\/td>\n<td>with<\/td>\n<td>yield<\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u7531\u4e8e Python \u662f\u4e25\u683c\u533a\u5206\u5927\u5c0f\u5199\u7684\uff0c\u4fdd\u7559\u5b57\u4e5f\u4e0d\u4f8b\u5916\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u53ef\u4ee5\u8bf4 if \u662f\u4fdd\u7559\u5b57\uff0c\u4f46 IF \u5c31\u4e0d\u662f\u4fdd\u7559\u5b57\u3002<\/p>\n<p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u5982\u679c\u4f7f\u7528 Python \u4e2d\u7684\u4fdd\u7559\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\uff0c\u5219\u89e3\u91ca\u5668\u4f1a\u63d0\u793a\u201cinvalid syntax\u201d \u7684\u9519\u8bef\u4fe1\u606f\uff0c\u5982\u56fe  \u6240\u793a\u3002<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/1-1Z6241FQ3419.jpg\" alt=\"\u4fdd\u7559\u5b57\u4f5c\u6807\u8bc6\u7b26\u62a5\u9519\u4fe1\u606f\u793a\u610f\u56fe\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4fdd\u7559\u5b57\u662fPython \u8bed\u8a00\u4e2d\u4e00\u4e9b\u5df2\u7ecf\u88ab\u8d4b\u4e88\u7279\u5b9a\u610f\u4e49\u7684\u5355\u8bcd\uff0c\u8fd9\u5c31\u8981\u6c42\u5f00\u53d1\u8005\u5728\u5f00\u53d1\u7a0b\u5e8f\u65f6\uff0c\u4e0d\u80fd\u7528\u8fd9\u4e9b\u4fdd\u7559\u5b57\u4f5c\u4e3a\u6807\u8bc6\u7b26\u7ed9\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u3001\u6a21\u677f\u4ee5   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[34],"tags":[159],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8721"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8721"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8721\/revisions"}],"predecessor-version":[{"id":8722,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/8721\/revisions\/8722"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8721"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8721"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8721"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}