{"id":1469,"date":"2024-05-13T15:02:05","date_gmt":"2024-05-13T07:02:05","guid":{"rendered":"https:\/\/17aitech.com\/?p=1469"},"modified":"2024-08-25T11:51:38","modified_gmt":"2024-08-25T03:51:38","slug":"2-python%e5%9f%ba%e6%9c%ac%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84","status":"publish","type":"post","link":"https:\/\/17aitech.com\/?p=1469","title":{"rendered":"2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 ez-toc-wrap-left-text counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u6587\u7ae0\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/17aitech.com\/?p=1469\/#Print%E8%AF%AD%E5%8F%A5%E6%89%A7%E8%A1%8C%E8%BF%87%E7%A8%8B\" >Print\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/17aitech.com\/?p=1469\/#Python_%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B\" >Python \u57fa\u672c\u6570\u636e\u7c7b\u578b<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E5%AD%97%E7%AC%A6%E4%B8%B2\" >\u5b57\u7b26\u4e32<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E6%95%B4%E6%95%B0\" >\u6574\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E6%B5%AE%E7%82%B9%E6%95%B0\" >\u6d6e\u70b9\u6570<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E5%B8%83%E5%B0%94%E5%80%BC\" >\u5e03\u5c14\u503c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E7%A9%BA%E5%80%BC\" >\u7a7a\u503c<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E7%BC%96%E7%A0%81%E9%97%AE%E9%A2%98\" >\u7f16\u7801\u95ee\u9898<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E7%BC%96%E7%A0%81%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5\" >\u7f16\u7801\u57fa\u672c\u6982\u5ff5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E7%BC%96%E7%A0%81%E5%8F%91%E5%B1%95%E8%BF%87%E7%A8%8B\" >\u7f16\u7801\u53d1\u5c55\u8fc7\u7a0b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/17aitech.com\/?p=1469\/#Unicode%E7%9A%84%E4%BA%A7%E7%94%9F%E8%83%8C%E6%99%AF%EF%BC%9A\" >Unicode\u7684\u4ea7\u751f\u80cc\u666f\uff1a<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\" >\u6ce8\u610f\u4e8b\u9879<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/17aitech.com\/?p=1469\/#Python%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2\" >Python\u57fa\u672c\u6570\u636e\u7c7b\u578b\u8f6c\u6362<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/17aitech.com\/?p=1469\/#Python%E4%B8%AD%E7%9A%84%E5%8F%98%E9%87%8F\" >Python\u4e2d\u7684\u53d8\u91cf<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E5%8F%98%E9%87%8F%E7%9A%84%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5\" >\u53d8\u91cf\u7684\u57fa\u672c\u6982\u5ff5<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E5%8F%98%E9%87%8F%E5%88%9B%E5%BB%BA%E5%92%8C%E8%B5%8B%E5%80%BC\" >\u53d8\u91cf\u521b\u5efa\u548c\u8d4b\u503c<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E5%8F%98%E9%87%8F%E7%9A%84%E8%B5%8B%E5%80%BC%E8%BF%87%E7%A8%8B\" >\u53d8\u91cf\u7684\u8d4b\u503c\u8fc7\u7a0b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E5%A4%9A%E4%B8%AA%E5%8F%98%E9%87%8F%E8%B5%8B%E5%80%BC\" >\u591a\u4e2a\u53d8\u91cf\u8d4b\u503c<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/17aitech.com\/?p=1469\/#%E9%99%84%E5%BD%95%EF%BC%9A\" >\u9644\u5f55\uff1a<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"Print%E8%AF%AD%E5%8F%A5%E6%89%A7%E8%A1%8C%E8%BF%87%E7%A8%8B\"><\/span>Print\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<pre><code class=\"language-python\">print(&#039;hello world&#039;)<\/code><\/pre>\n<p>print() \u51fd\u6570\u7531\u4e24\u90e8\u5206\u6784\u6210 \uff1a<\/p>\n<ul>\n<li>\u6307\u4ee4\uff1aprint<\/li>\n<li>\u6307\u4ee4\u7684\u6267\u884c\u5bf9\u8c61\uff0c\u5728 print \u540e\u9762\u7684\u62ec\u53f7\u91cc\u7684\u5185\u5bb9<\/li>\n<\/ul>\n<p>\u5b83\u7684\u6267\u884c\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n<pre><code class=\"language-mermaid\">flowchart TD\n    A[&quot;print(&#039;hello world&#039;)&quot;] --&gt;|\u5411\u89e3\u91ca\u5668\u53d1\u51fa\u6307\u4ee4\u6253\u5370&#039;hello world&#039;| B(Python\u89e3\u91ca\u5668)\n    B --&gt; |\u89e3\u6790\u5668\u628a\u4ee3\u7801\u89e3\u91ca\u4e3a\u8ba1\u7b97\u5668\u80fd\u8bfb\u61c2\u7684\u673a\u5668\u8bed\u8a00| C(\u8ba1\u7b97\u673a)\n    C --&gt;|\u8ba1\u7b97\u673a\u6267\u884c\u5b8c\u540e\u5c31\u6253\u5370\u7ed3\u679c| D[hello world]<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Python_%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B\"><\/span>Python \u57fa\u672c\u6570\u636e\u7c7b\u578b<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"%E5%AD%97%E7%AC%A6%E4%B8%B2\"><\/span>\u5b57\u7b26\u4e32<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5b57\u7b26\u4e32\u662fpython\u4e2d\u6700\u5e38\u7528\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5b57\u7b26\u4e32\u7684\u8bc6\u522b\u4e5f\u975e\u5e38\u7684\u7b80\u5355\uff0c\u5c31\u662f\u7528\u300c\u5f15\u53f7\u300d\u62ec\u8d77\u6765\u7684\u3002<\/p>\n<p>\u5728Python\u4e2d\uff0c\u5f15\u53f7\u7528\u4e8e\u5b9a\u4e49\u5b57\u7b26\u4e32\uff0c\u5305\u62ec\u5355\u5f15\u53f7(\u2019 \u2018)\u3001\u53cc\u5f15\u53f7(&quot; &quot;)\u548c\u4e09\u5f15\u53f7(\u2019\u2018\u2019 \u2018\u2019)\u3002\u8fd9\u4e9b\u5f15\u53f7\u7684\u9009\u62e9\u548c\u4f7f\u7528\u53d6\u51b3\u4e8e\u4e0d\u540c\u7684\u4f7f\u7528\u573a\u666f\uff1a<\/p>\n<p><strong>\u5355\u5f15\u53f7\uff08&#8217;\uff09<\/strong>\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u573a\u666f\uff1a\u901a\u5e38\u7528\u4e8e\u7b80\u5355\u7684\u5b57\u7b26\u4e32\uff0c\u4f8b\u5982\u5355\u8bcd\u6216\u77ed\u8bed\u3002<\/li>\n<li>\u793a\u4f8b\uff1a\n<pre><code class=\"language-python\">name = &#039;Alice&#039;<\/code><\/pre>\n<\/li>\n<\/ul>\n<p><strong>\u53cc\u5f15\u53f7\uff08&quot;\uff09<\/strong>\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u573a\u666f\uff1a\u4e0e\u5355\u5f15\u53f7\u7c7b\u4f3c\uff0c\u4e5f\u7528\u4e8e\u8868\u793a\u5b57\u7b26\u4e32\uff0c\u901a\u5e38\u5728\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u5355\u5f15\u53f7\u65f6\u4f7f\u7528\u3002<\/li>\n<li>\u793a\u4f8b\uff1a\n<pre><code class=\"language-python\">message = &quot;It&#039;s a beautiful day&quot;<\/code><\/pre>\n<\/li>\n<\/ul>\n<p><strong>\u4e09\u5f15\u53f7\uff08&#8221;&#8217;\u6216&quot;&quot;&quot;\uff09<\/strong>\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528\u573a\u666f\uff1a\u7528\u4e8e\u591a\u884c\u5b57\u7b26\u4e32\u3001\u6587\u6863\u5b57\u7b26\u4e32\uff08docstring\uff09\u6216\u5305\u542b\u6362\u884c\u7b26\u7684\u957f\u5b57\u7b26\u4e32\u3002<\/li>\n<li>\u793a\u4f8b:\n<pre><code class=\"language-python\">long_text = &#039;&#039;&#039;This is a \n           multiline \n           string&#039;&#039;&#039;\ndocstring_example = &quot;&quot;&quot;\nThis is a docstring.\nIt is used to provide documentation for functions, modules, or classes.\n&quot;&quot;&quot;<\/code><\/pre>\n<blockquote>\n<p>\u5907\u6ce8\uff1a\u4e09\u5f15\u53f7\u5b9a\u4e49\u7684\u5b57\u7b26\u4e32\uff0c\u5141\u8bb8\u5b57\u7b26\u4e32\u8de8\u8d8a\u591a\u884c\uff0c\u800c\u4e0d\u9700\u8981\u5728\u6bcf\u884c\u672b\u5c3e\u6dfb\u52a0\u8fde\u884c\u7b26\u3002\u6b64\u5916\uff0c\u4e09\u5f15\u53f7\u5b57\u7b26\u4e32\u53ef\u4ee5\u5305\u542b\u7279\u6b8a\u5b57\u7b26\uff0c\u5305\u62ec\u5355\u5f15\u53f7\u548c\u53cc\u5f15\u53f7\uff0c\u800c\u65e0\u9700\u8f6c\u4e49\u3002<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"%E6%95%B4%E6%95%B0\"><\/span>\u6574\u6570<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5728Python\u4e2d\uff0c\u6574\u6570\u662f\u4e00\u79cd\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u7528\u4e8e\u8868\u793a\u6574\u6570\u503c\u3002<\/p>\n<ul>\n<li>\n<p><strong>\u6574\u6570\u7c7b\u578b<\/strong>\uff1aPython\u4e2d\u7684\u6574\u6570\u7c7b\u578b\u662fint\uff0c\u53ef\u4ee5\u8868\u793a\u6b63\u6574\u6570\u3001\u8d1f\u6574\u6570\u548c\u96f6\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6574\u6570\u8fd0\u7b97<\/strong>\uff1aPython\u652f\u6301\u5e38\u89c1\u7684\u6574\u6570\u8fd0\u7b97\uff0c\u5305\u62ec\u52a0\u6cd5\uff08+\uff09\u3001\u51cf\u6cd5\uff08-\uff09\u3001\u4e58\u6cd5\uff08*\uff09\u3001\u9664\u6cd5\uff08\/\uff09\u3001\u53d6\u6a21\uff08%\uff09\u548c\u5e42\u8fd0\u7b97\uff08**\uff09\u7b49\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\"># \u58f0\u660e\u6574\u6570\u53d8\u91cf\nnum1 = 10\nnum2 = 5\n\n# \u52a0\u6cd5\nsum_result = num1 + num2\nprint(&quot;Sum:&quot;, sum_result)\n\n# \u51cf\u6cd5\nsubtraction_result = num1 - num2\nprint(&quot;Subtraction:&quot;, subtraction_result)\n\n# \u4e58\u6cd5\nmultiplication_result = num1 * num2\nprint(&quot;Multiplication:&quot;, multiplication_result)\n\n# \u9664\u6cd5\ndivision_result = num1 \/ num2\nprint(&quot;Division:&quot;, division_result)\n\n# \u53d6\u6a21\nmodulus_result = num1 % num2\nprint(&quot;Modulus:&quot;, modulus_result)\n\n# \u5e42\u8fd0\u7b97\npower_result = num1 ** num2\nprint(&quot;Power:&quot;, power_result)\n<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"%E6%B5%AE%E7%82%B9%E6%95%B0\"><\/span>\u6d6e\u70b9\u6570<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5728Python\u4e2d\uff0c\u6d6e\u70b9\u6570\u662f\u4e00\u79cd\u7528\u4e8e\u8868\u793a\u5c0f\u6570\u7684\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<ul>\n<li>\n<p><strong>\u6d6e\u70b9\u6570\u7c7b\u578b<\/strong>\uff1aPython\u4e2d\u7684\u6d6e\u70b9\u6570\u7c7b\u578b\u662ffloat\uff0c\u7528\u4e8e\u8868\u793a\u5e26\u6709\u5c0f\u6570\u90e8\u5206\u7684\u6570\u5b57\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6d6e\u70b9\u6570\u8fd0\u7b97<\/strong>\uff1aPython\u652f\u6301\u5e38\u89c1\u7684\u6d6e\u70b9\u6570\u8fd0\u7b97\uff0c\u5305\u62ec\u52a0\u6cd5\uff08+\uff09\u3001\u51cf\u6cd5\uff08-\uff09\u3001\u4e58\u6cd5\uff08*\uff09\u3001\u9664\u6cd5\uff08\/\uff09\u548c\u5e42\u8fd0\u7b97\uff08**\uff09\u7b49\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\"># \u58f0\u660e\u6d6e\u70b9\u6570\u53d8\u91cf\nnum1 = 3.5\nnum2 = 2.0\n\n# \u52a0\u6cd5\nsum_result = num1 + num2\nprint(&quot;Sum:&quot;, sum_result)\n\n# \u51cf\u6cd5\nsubtraction_result = num1 - num2\nprint(&quot;Subtraction:&quot;, subtraction_result)\n\n# \u4e58\u6cd5\nmultiplication_result = num1 * num2\nprint(&quot;Multiplication:&quot;, multiplication_result)\n\n# \u9664\u6cd5\ndivision_result = num1 \/ num2\nprint(&quot;Division:&quot;, division_result)\n\n# \u5e42\u8fd0\u7b97\npower_result = num1 ** num2\nprint(&quot;Power:&quot;, power_result)<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"%E5%B8%83%E5%B0%94%E5%80%BC\"><\/span>\u5e03\u5c14\u503c<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5e03\u5c14\u503c\u662fPython\u4e2d\u7684\u4e00\u79cd\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff0c\u7528\u4e8e\u8868\u793a\u903b\u8f91\u503c\u3002\u5e03\u5c14\u503c\u6709\u4e24\u4e2a\u53d6\u503c\uff1aTrue\uff08\u771f\uff09\u548cFalse\uff08\u5047\uff09\u3002\u5e03\u5c14\u7c7b\u578b\u5728\u63a7\u5236\u6d41\u8bed\u53e5\u3001\u903b\u8f91\u8fd0\u7b97\u548c\u6761\u4ef6\u5224\u65ad\u4e2d\u975e\u5e38\u5e38\u7528\u3002<\/p>\n<ul>\n<li>\n<p><strong>\u5e03\u5c14\u7c7b\u578b<\/strong>\uff1aPython\u4e2d\u7684\u5e03\u5c14\u7c7b\u578b\u662fbool\uff0c\u53ea\u6709\u4e24\u4e2a\u53d6\u503c\uff1aTrue\u548cFalse\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u903b\u8f91\u8fd0\u7b97<\/strong>\uff1aPython\u4e2d\u7684\u903b\u8f91\u8fd0\u7b97\u7b26\u5305\u62ec\u4e0e\uff08and\uff09\u3001\u6216\uff08or\uff09\u548c\u975e\uff08not\uff09\uff0c\u7528\u4e8e\u7ec4\u5408\u548c\u64cd\u4f5c\u5e03\u5c14\u503c\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\"># \u58f0\u660e\u5e03\u5c14\u53d8\u91cf\nis_raining = True\nis_sunny = False\n\n# \u903b\u8f91\u8fd0\u7b97\u793a\u4f8b\n# \u4e0e\u8fd0\u7b97\nprint(&quot;is_raining and is_sunny:&quot;, is_raining and is_sunny)\n\n# \u6216\u8fd0\u7b97\nprint(&quot;is_raining or is_sunny:&quot;, is_raining or is_sunny)\n\n# \u975e\u8fd0\u7b97\nprint(&quot;not is_raining:&quot;, not is_raining)<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"%E7%A9%BA%E5%80%BC\"><\/span>\u7a7a\u503c<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5728Python\u4e2d\uff0c\u7a7a\u503c\u7528None\u8868\u793a\uff0c\u5b83\u662f\u4e00\u4e2a\u7279\u6b8a\u7684\u6570\u636e\u7c7b\u578b\uff0c\u7528\u4e8e\u8868\u793a\u201c\u7a7a\u201d\u3001\u201c\u65e0\u201d\u6216\u201c\u4e0d\u5b58\u5728\u201d\u7684\u6982\u5ff5\u3002None\u5728Python\u4e2d\u901a\u5e38\u7528\u4e8e\u8868\u793a\u4e00\u4e2a\u53d8\u91cf\u5c1a\u672a\u88ab\u8d4b\u503c\uff0c\u6216\u8005\u51fd\u6570\u6ca1\u6709\u8fd4\u56de\u503c\u65f6\u4f7f\u7528\u3002<\/p>\n<ul>\n<li><strong>\u7a7a\u503c\u7c7b\u578b<\/strong>\uff1aPython\u4e2d\u7684\u7a7a\u503c\u7c7b\u578b\u662fNone\uff0c\u5b83\u8868\u793a\u4e00\u4e2a\u7a7a\u5bf9\u8c61\u6216\u7f3a\u5c11\u503c\u3002<\/li>\n<\/ul>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\"># \u58f0\u660e\u4e00\u4e2a\u53d8\u91cf\u5e76\u8d4b\u4e88\u7a7a\u503cNone\nempty_variable = None\n\n# \u5224\u65ad\u53d8\u91cf\u662f\u5426\u4e3aNone\nif empty_variable is None:\n    print(&quot;The variable is empty (None)&quot;)\nelse:\n    print(&quot;The variable is not empty&quot;)\n<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"%E7%BC%96%E7%A0%81%E9%97%AE%E9%A2%98\"><\/span>\u7f16\u7801\u95ee\u9898<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Python\u4e2d\uff0c\u7f16\u7801\u662f\u6781\u5176\u5bb9\u6613\u51fa\u9519\u7684\u5730\u65b9\uff0c\u6240\u4ee5\u672c\u8282\u91cd\u70b9\u5bf9\u7f16\u7801\u7684\u8fc7\u7a0b\u4ee5\u53ca\u53d1\u5c55\u8fc7\u7a0b\u505a\u7b80\u8981\u4ecb\u7ecd\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E7%BC%96%E7%A0%81%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5\"><\/span>\u7f16\u7801\u57fa\u672c\u6982\u5ff5<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u7f16\u7801\u662f\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u8ba1\u7b97\u673a\u53ef\u8bc6\u522b\u7684\u5b57\u8282\u5e8f\u5217\u7684\u8fc7\u7a0b\u3002\u5728\u8ba1\u7b97\u673a\u4e2d\uff0c\u6240\u6709\u7684\u6570\u636e\u6700\u7ec8\u90fd\u662f\u4ee5\u4e8c\u8fdb\u5236\u5f62\u5f0f\u5b58\u50a8\u548c\u5904\u7406\u7684\u3002\u4e0d\u540c\u7684\u7f16\u7801\u65b9\u6848\u89c4\u5b9a\u4e86\u5b57\u7b26\u548c\u5b57\u8282\u4e4b\u95f4\u7684\u5bf9\u5e94\u5173\u7cfb\uff0c\u4ee5\u4fbf\u8ba1\u7b97\u673a\u80fd\u591f\u6b63\u786e\u5730\u89e3\u91ca\u548c\u663e\u793a\u6587\u672c\u6570\u636e\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E7%BC%96%E7%A0%81%E5%8F%91%E5%B1%95%E8%BF%87%E7%A8%8B\"><\/span>\u7f16\u7801\u53d1\u5c55\u8fc7\u7a0b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\n<p>ASCII\u7f16\u7801\uff08American Standard Code for Information Interchange\uff09\uff1a<\/p>\n<blockquote>\n<p>ASCII\u662f\u6700\u65e9\u7684\u5b57\u7b26\u7f16\u7801\u65b9\u6848\uff0c\u4f7f\u75287\u4f4d\u62168\u4f4d\u8868\u793a\u4e00\u4e2a\u5b57\u7b26\uff0c\u6700\u521d\u4ec5\u5305\u542b\u82f1\u6587\u5b57\u7b26\u548c\u4e00\u4e9b\u7279\u6b8a\u7b26\u53f7\u3002<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>\u4e2d\u6587\u7f16\u7801\uff1a<\/p>\n<blockquote>\n<p>\u968f\u7740\u8ba1\u7b97\u673a\u7684\u666e\u53ca\uff0c\u51fa\u73b0\u4e86\u8bb8\u591a\u4e2d\u6587\u7f16\u7801\u65b9\u6848\uff0c\u5982GB2312\u3001BIG5\u7b49\uff0c\u7528\u4e8e\u8868\u793a\u4e2d\u6587\u5b57\u7b26\u96c6\u3002\u8fd9\u4e9b\u7f16\u7801\u65b9\u6848\u5404\u4e0d\u76f8\u540c\uff0c\u5bfc\u81f4\u4e86\u4e0d\u540c\u7cfb\u7edf\u4e4b\u95f4\u7684\u4e2d\u6587\u5b57\u7b26\u663e\u793a\u4e71\u7801\u95ee\u9898\u3002<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>Unicode\u7f16\u7801\uff1a<\/p>\n<blockquote>\n<p>\u4e3a\u89e3\u51b3\u5b57\u7b26\u96c6\u591a\u6837\u6027\u548c\u517c\u5bb9\u6027\u95ee\u9898\uff0cUnicode\u5e94\u8fd0\u800c\u751f\u3002Unicode\u662f\u4e00\u79cd\u5168\u7403\u5b57\u7b26\u96c6\u6807\u51c6\uff0c\u5305\u62ec\u4e86\u4e16\u754c\u4e0a\u51e0\u4e4e\u6240\u6709\u7684\u6587\u5b57\u548c\u7b26\u53f7\uff0c\u4e3a\u6bcf\u4e2a\u5b57\u7b26\u5206\u914d\u4e86\u552f\u4e00\u7684\u7f16\u53f7\u3002<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>UTF-8\u7f16\u7801\uff08Unicode Transformation Format &#8211; 8-bit\uff09\uff1a<\/p>\n<blockquote>\n<p>UTF-8\u662f\u4e00\u79cd\u53ef\u53d8\u957f\u5ea6\u7684Unicode\u7f16\u7801\u65b9\u5f0f\uff0c\u75281\u81f34\u4e2a\u5b57\u8282\u8868\u793a\u4e00\u4e2a\u5b57\u7b26\uff0c\u517c\u5bb9ASCII\u7f16\u7801\u3002\u5b83\u6210\u4e3aWeb\u5f00\u53d1\u4e2d\u6700\u5e38\u7528\u7684\u7f16\u7801\u65b9\u5f0f\u4e4b\u4e00\u3002<\/p>\n<\/blockquote>\n<\/li>\n<li>\n<p>UTF-16\u7f16\u7801\uff1a<\/p>\n<blockquote>\n<p>UTF-16\u662f\u4e00\u79cd\u56fa\u5b9a\u957f\u5ea6\u7684Unicode\u7f16\u7801\u65b9\u5f0f\uff0c\u75282\u62164\u4e2a\u5b57\u8282\u8868\u793a\u4e00\u4e2a\u5b57\u7b26\uff0c\u9002\u5408\u5904\u7406\u8f83\u591a\u6587\u5b57\u7684\u8bed\u8a00\u3002<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"Unicode%E7%9A%84%E4%BA%A7%E7%94%9F%E8%83%8C%E6%99%AF%EF%BC%9A\"><\/span>Unicode\u7684\u4ea7\u751f\u80cc\u666f\uff1a<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5728\u8fc7\u53bb\uff0c\u4e0d\u540c\u56fd\u5bb6\u548c\u5730\u533a\u4f7f\u7528\u4e0d\u540c\u7684\u5b57\u7b26\u96c6\u548c\u7f16\u7801\u65b9\u5f0f\uff0c\u5bfc\u81f4\u4e86\u8de8\u8bed\u8a00\u901a\u4fe1\u548c\u6570\u636e\u4ea4\u6362\u7684\u56f0\u96be\u3002\u4e3a\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0cUnicode\u5e94\u8fd0\u800c\u751f\u3002<\/p>\n<ul>\n<li>Unicode\u7684\u76ee\u6807\u662f\u4e3a\u4e16\u754c\u4e0a\u6bcf\u4e2a\u5b57\u7b26\u63d0\u4f9b\u4e00\u4e2a\u552f\u4e00\u7684\u6807\u8bc6\u7b26\u3002\u5b83\u5305\u542b\u4e86\u5168\u7403\u8303\u56f4\u5185\u51e0\u4e4e\u6240\u6709\u7684\u6587\u5b57\u548c\u7b26\u53f7\uff0c\u5e76\u4e3a\u6bcf\u4e2a\u5b57\u7b26\u5206\u914d\u4e86\u552f\u4e00\u7684\u7f16\u53f7\uff08\u7801\u70b9\uff09\u3002<\/li>\n<li>Unicode\u7684\u4ea7\u751f\u80cc\u666f\u662f\u4e3a\u4e86\u7edf\u4e00\u5b57\u7b26\u7f16\u7801\u65b9\u5f0f\uff0c\u4f7f\u5f97\u4e0d\u540c\u7cfb\u7edf\u548c\u8f6f\u4ef6\u4e4b\u95f4\u80fd\u591f\u6b63\u786e\u5730\u663e\u793a\u548c\u5904\u7406\u5404\u79cd\u8bed\u8a00\u7684\u6587\u5b57\u548c\u7b26\u53f7\u3002<\/li>\n<li>Unicode\u7684\u51fa\u73b0\u6781\u5927\u5730\u7b80\u5316\u4e86\u8de8\u8bed\u8a00\u901a\u4fe1\u548c\u6570\u636e\u4ea4\u6362\u7684\u590d\u6742\u6027\uff0c\u6210\u4e3a\u8ba1\u7b97\u673a\u9886\u57df\u4e2d\u6700\u91cd\u8981\u7684\u5b57\u7b26\u96c6\u6807\u51c6\u4e4b\u4e00\u3002<\/li>\n<\/ul>\n<pre><code>+----------------+          +----------------+          +----------------+\n|    \u5b57\u7b26\u4e32      |  \u7f16\u7801     |    \u5b57\u8282\u5e8f\u5217    |  \u89e3\u7801    |    \u5b57\u7b26\u4e32      |\n|   (Unicode)    |  ----&gt;   |    (\u5b57\u8282\u5e8f\u5217)  |  ----&gt;   |   (Unicode)    |\n+----------------+          +----------------+          +----------------+<\/code><\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u56fe\u793a\u4e2d\uff0c\u5b57\u7b26\u4e32\uff08Unicode\uff09\u9996\u5148\u7ecf\u8fc7\u7f16\u7801\u8fc7\u7a0b\u8f6c\u6362\u4e3a\u5b57\u8282\u5e8f\u5217\uff0c\u7136\u540e\u5728\u9700\u8981\u65f6\u901a\u8fc7\u89e3\u7801\u8fc7\u7a0b\u5c06\u5b57\u8282\u5e8f\u5217\u91cd\u65b0\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\uff08Unicode\uff09\u3002\u7f16\u7801\u548c\u89e3\u7801\u662f\u5b57\u7b26\u4e32\u5728\u8ba1\u7b97\u673a\u4e2d\u4f20\u8f93\u3001\u5b58\u50a8\u548c\u5904\u7406\u8fc7\u7a0b\u4e2d\u5fc5\u4e0d\u53ef\u5c11\u7684\u6b65\u9aa4\uff0c\u786e\u4fdd\u4e86\u4e0d\u540c\u7cfb\u7edf\u4e4b\u95f4\u7684\u6570\u636e\u4ea4\u6362\u548c\u517c\u5bb9\u6027\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9\"><\/span>\u6ce8\u610f\u4e8b\u9879<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>\n<p>\u56e0\u4e3a Python \u7684\u8bde\u751f\u6bd4 Unicode \u6807\u51c6\u53d1\u5e03\u7684\u65f6\u95f4\u8fd8\u8981\u65e9\uff0c\u6240\u4ee5\u6700\u65e9\u7684Python \u53ea\u652f\u6301 ASCII \u7f16\u7801\uff0c\u666e\u901a\u7684\u5b57\u7b26\u4e32 &#8216;ABC&#8217; \u5728 Python \u5185\u90e8\u90fd\u662f ASCII \u7f16\u7801\u7684\u3002<\/p>\n<\/li>\n<li>\n<p>Python \u5728\u540e\u6765\u6dfb\u52a0\u4e86\u5bf9 Unicode \u7684\u652f\u6301\uff0c\u4ee5 Unicode \u8868\u793a\u7684\u5b57\u7b26\u4e32\u7528u&#8217;&#8230;&#8217;\u8868\u793a\u3002<\/p>\n<\/li>\n<li>\n<p>\u4e0d\u8fc7\u5728\u6700\u65b0\u7684 Python 3 \u7248\u672c\u4e2d\uff0c\u5b57\u7b26\u4e32\u662f\u4ee5 Unicode \u7f16\u7801\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0cPython \u7684\u5b57\u7b26\u4e32\u652f\u6301\u591a\u8bed\u8a00\uff0c\u4ee3\u7801\u4e2d\u6ca1\u6709\u52a0u&#8217;&#8230;&#8217;\uff0c\u4e5f\u80fd\u6b63\u5e38\u663e\u793a\u3002<\/p>\n<\/li>\n<li>\n<p>\u7531\u4e8e Python \u6e90\u4ee3\u7801\u4e5f\u662f\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\uff0c\u6240\u4ee5\uff0c\u5f53\u4f60\u7684\u6e90\u4ee3\u7801\u4e2d\u5305\u542b\u4e2d\u6587\u7684\u65f6\u5019\uff0c\u5728\u4fdd\u5b58\u6e90\u4ee3\u7801\u65f6\uff0c\u5c31\u9700\u8981\u52a1\u5fc5\u6307\u5b9a\u4fdd\u5b58\u4e3a UTF-8 \u7f16\u7801\u3002\u5f53Python \u89e3\u91ca\u5668\u8bfb\u53d6\u6e90\u4ee3\u7801\u65f6\uff0c\u4e3a\u4e86\u8ba9\u5b83\u6309 UTF-8 \u7f16\u7801\u8bfb\u53d6\uff0c\u6211\u4eec\u901a\u5e38\u5728\u6587\u4ef6\u5f00\u5934\u5199\u4e0a\u8fd9\u4e24\u884c\uff1a<\/p>\n<pre><code class=\"language-python\">#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-<\/code><\/pre>\n<blockquote>\n<p>\u7b2c\u4e00\u884c\u6ce8\u91ca\u662f\u4e3a\u4e86\u544a\u8bc9 Linux\/OS X \u7cfb\u7edf\uff0c\u8fd9\u662f\u4e00\u4e2a Python \u53ef\u6267\u884c\u7a0b\u5e8f\uff0cWindows \u7cfb\u7edf\u4f1a\u5ffd\u7565\u8fd9\u4e2a\u6ce8\u91ca\uff1b<\/p>\n<p>\u7b2c\u4e8c\u884c\u6ce8\u91ca\u662f\u4e3a\u4e86\u544a\u8bc9 Python \u89e3\u91ca\u5668\uff0c\u6309\u7167 UTF-8 \u7f16\u7801\u8bfb\u53d6\u6e90\u4ee3\u7801\uff0c\u5426\u5219\uff0c\u4f60\u5728\u6e90\u4ee3\u7801\u4e2d\u5199\u7684\u4e2d\u6587\u8f93\u51fa\u53ef\u80fd\u4f1a\u6709\u4e71\u7801\u3002<\/p>\n<p>\u7533\u660e\u4e86 UTF-8 \u7f16\u7801\u5e76\u4e0d\u610f\u5473\u7740\u4f60\u7684 .py \u6587\u4ef6\u5c31\u662f UTF-8 \u7f16\u7801\u7684\uff0c\u5fc5\u987b\u5e76\u4e14\u8981\u786e\u4fdd\u6587\u672c\u7f16\u8f91\u5668\u6b63\u5728\u4f7f\u7528 UTF-8 without BOM \u7f16\u7801<\/p>\n<\/blockquote>\n<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Python%E5%9F%BA%E6%9C%AC%E6%95%B0%E6%8D%AE%E7%B1%BB%E5%9E%8B%E8%BD%AC%E6%8D%A2\"><\/span>Python\u57fa\u672c\u6570\u636e\u7c7b\u578b\u8f6c\u6362<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u65b9\u6cd5<\/th>\n<th style=\"text-align: left;\">\u65b9\u6cd5\u4f5c\u7528<\/th>\n<th style=\"text-align: left;\">\u793a\u4f8b\u4ee3\u7801<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\">int(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u6574\u6570<\/td>\n<td style=\"text-align: left;\">num_str = &#8217;10&#8217; <br \/> num_int = int(num_str)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">float(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570<\/td>\n<td style=\"text-align: left;\">num_str = &#8216;3.14&#8217; <br \/> num_float = float(num_str)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">str(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32<\/td>\n<td style=\"text-align: left;\">num_int = 10 <br \/> num_str = str(num_int)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">bool(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u5e03\u5c14\u503c<\/td>\n<td style=\"text-align: left;\">num = 0 <br \/> bool_num = bool(num)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">list(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u5217\u8868<\/td>\n<td style=\"text-align: left;\">tuple_var = (1, 2, 3) <br \/> list_var = list(tuple_var)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">tuple(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u5143\u7ec4<\/td>\n<td style=\"text-align: left;\">list_var = [1, 2, 3] <br \/> tuple_var = tuple(list_var)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">set(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u96c6\u5408<\/td>\n<td style=\"text-align: left;\">list_var = [1, 2, 3, 2] <br \/> set_var = set(list_var)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">dict(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u5b57\u5178<\/td>\n<td style=\"text-align: left;\">tuple_list = [(1, &#8216;one&#8217;), (2, &#8216;two&#8217;)] <br \/> dict_var = dict(tuple_list)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">complex(x)<\/td>\n<td style=\"text-align: left;\">\u5c06x\u8f6c\u6362\u4e3a\u590d\u6570<\/td>\n<td style=\"text-align: left;\">complex_num = complex(3, 4)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">repr(x)<\/td>\n<td style=\"text-align: left;\">\u8fd4\u56de\u5305\u542b\u5bf9\u8c61\u53ef\u6253\u5370\u8868\u793a\u7684\u5b57\u7b26\u4e32<\/td>\n<td style=\"text-align: left;\">str_var = &#8216;Hello&#8217; <br \/> repr_str = repr(str_var)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">chr(x)<\/td>\n<td style=\"text-align: left;\">\u8fd4\u56deUnicode\u4ee3\u7801\u70b9x\u5bf9\u5e94\u7684\u5b57\u7b26<\/td>\n<td style=\"text-align: left;\">unicode_char = chr(65)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">unichr(x)<\/td>\n<td style=\"text-align: left;\">\u8fd4\u56deUnicode\u4ee3\u7801\u70b9x\u5bf9\u5e94\u7684\u5b57\u7b26<\/td>\n<td style=\"text-align: left;\">unicode_char = unichr(65)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">ord(x)<\/td>\n<td style=\"text-align: left;\">\u8fd4\u56de\u5b57\u7b26\u7684Unicode\u4ee3\u7801\u70b9\u503c<\/td>\n<td style=\"text-align: left;\">unicode_char = &#8216;A&#8217; <br \/> unicode_code = ord(unicode_char)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">hex(x)<\/td>\n<td style=\"text-align: left;\">\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u5341\u516d\u8fdb\u5236\u5b57\u7b26\u4e32<\/td>\n<td style=\"text-align: left;\">num_int = 16 <br \/> hex_str = hex(num_int)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\">oct(x)<\/td>\n<td style=\"text-align: left;\">\u5c06\u6574\u6570\u8f6c\u6362\u4e3a\u516b\u8fdb\u5236\u5b57\u7b26\u4e32<\/td>\n<td style=\"text-align: left;\">num_int = 8 <br \/> oct_str = oct(num_int)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><span class=\"ez-toc-section\" id=\"Python%E4%B8%AD%E7%9A%84%E5%8F%98%E9%87%8F\"><\/span>Python\u4e2d\u7684\u53d8\u91cf<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"%E5%8F%98%E9%87%8F%E7%9A%84%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5\"><\/span>\u53d8\u91cf\u7684\u57fa\u672c\u6982\u5ff5<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>\u5728Python\u4e2d\uff0c\u53d8\u91cf\u662f\u7528\u4e8e\u5b58\u50a8\u6570\u636e\u503c\u7684\u6807\u8bc6\u7b26\u3002\u53d8\u91cf\u53ef\u4ee5\u901a\u8fc7\u8d4b\u503c\u6765\u521b\u5efa\uff0c\u5e76\u5728\u7a0b\u5e8f\u4e2d\u88ab\u5f15\u7528\u548c\u4fee\u6539\u3002\u53d8\u91cf\u5728\u5185\u5b58\u4e2d\u5206\u914d\u7a7a\u95f4\uff0c\u7528\u4e8e\u5b58\u50a8\u6570\u636e\uff0c\u5e76\u53ef\u4ee5\u6839\u636e\u9700\u8981\u6307\u5411\u4e0d\u540c\u7684\u6570\u636e\u503c\u3002<\/p>\n<h4><span class=\"ez-toc-section\" id=\"%E5%8F%98%E9%87%8F%E5%88%9B%E5%BB%BA%E5%92%8C%E8%B5%8B%E5%80%BC\"><\/span>\u53d8\u91cf\u521b\u5efa\u548c\u8d4b\u503c<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-python\"># \u53d8\u91cf\u521b\u5efa\u548c\u8d4b\u503c\u793a\u4f8b\nname = &quot;Alice&quot;  # \u521b\u5efa\u4e00\u4e2a\u540d\u4e3aname\u7684\u53d8\u91cf\uff0c\u5e76\u8d4b\u503c\u4e3a&quot;Alice&quot;\nage = 30        # \u521b\u5efa\u4e00\u4e2a\u540d\u4e3aage\u7684\u53d8\u91cf\uff0c\u5e76\u8d4b\u503c\u4e3a30<\/code><\/pre>\n<h4><span class=\"ez-toc-section\" id=\"%E5%8F%98%E9%87%8F%E7%9A%84%E8%B5%8B%E5%80%BC%E8%BF%87%E7%A8%8B\"><\/span>\u53d8\u91cf\u7684\u8d4b\u503c\u8fc7\u7a0b<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<pre><code class=\"language-python\">x = 10\ny = 20\nz = x<\/code><\/pre>\n<pre><code class=\"language-mermaid\">graph LR\n    A[&quot;x = 10&quot;] --&gt; B[&quot;y = 20&quot;]\n    B --&gt; C[&quot;z = x&quot;]\n    A -.-&gt; D[&quot;10&quot;]\n    B -.-&gt; E[&quot;20&quot;]\n    D --&gt; C\n    E --&gt; C\n<\/code><\/pre>\n<blockquote>\n<p>\u5728\u4e0a\u4f8b\u4e2d \uff1a\u53d8\u91cfx\u88ab\u8d4b\u503c\u4e3a10\uff0c\u53d8\u91cfy\u88ab\u8d4b\u503c\u4e3a20\u3002\u7136\u540e\uff0c\u53d8\u91cfz\u88ab\u8d4b\u503c\u4e3ax\uff0c\u56e0\u6b64z\u6307\u5411\u4e0ex\u76f8\u540c\u7684\u5185\u5b58\u5730\u5740\uff0c\u5373\u5b83\u4eec\u90fd\u6307\u5411\u5b58\u50a8\u503c\u4e3a10\u7684\u5185\u5b58\u4f4d\u7f6e\u3002<\/p>\n<\/blockquote>\n<h4><span class=\"ez-toc-section\" id=\"%E5%A4%9A%E4%B8%AA%E5%8F%98%E9%87%8F%E8%B5%8B%E5%80%BC\"><\/span>\u591a\u4e2a\u53d8\u91cf\u8d4b\u503c<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Python \u5141\u8bb8\u540c\u65f6\u4e3a\u591a\u4e2a\u53d8\u91cf\u8d4b\u503c\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">a = b = c = 1<\/code><\/pre>\n<p>\u4ee5\u4e0a\u5b9e\u4f8b\uff0c\u521b\u5efa\u4e00\u4e2a\u6574\u578b\u5bf9\u8c61\uff0c\u503c\u4e3a 1\uff0c\u4e09\u4e2a\u53d8\u91cf\u88ab\u5206\u914d\u5230\u76f8\u540c\u7684\u5185\u5b58\u7a7a\u95f4\u4e0a\u3002<\/p>\n<p>\u5f53\u7136\u4e5f\u53ef\u4ee5\u4e3a\u591a\u4e2a\u5bf9\u8c61\u6307\u5b9a\u591a\u4e2a\u53d8\u91cf\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-python\">a, b, c = 1, 2, &quot;liangdianshui&quot;<\/code><\/pre>\n<p>\u4ee5\u4e0a\u5b9e\u4f8b\uff0c\u4e24\u4e2a\u6574\u578b\u5bf9\u8c61 1 \u548c 2 \u7684\u5206\u914d\u7ed9\u53d8\u91cf a \u548c b\uff0c\u5b57\u7b26\u4e32\u5bf9\u8c61 &quot;liangdianshui&quot; \u5206\u914d\u7ed9\u53d8\u91cf c\u3002<\/p>\n<h2><span class=\"ez-toc-section\" id=\"%E9%99%84%E5%BD%95%EF%BC%9A\"><\/span>\u9644\u5f55\uff1a<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>\u4ee5\u4e0a\u5185\u5bb9\u90e8\u5206\u53c2\u8003\u81ea\u300a<a href=\"https:\/\/blog.csdn.net\/lizhongjun1005\/article\/details\/135192233\">Python\u6559\u7a0b\u7b2c2\u7ae0 | \u57fa\u672c\u6570\u636e\u7c7b\u578b\u548c\u53d8\u91cf<\/a>\u300b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Print\u8bed\u53e5\u6267\u884c\u8fc7\u7a0b print(&#038;# [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1638,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[28],"tags":[49],"class_list":["post-1469","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-blog","tag-python","post_format-post-format-aside"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784 - \u4e00\u8d77AI\u6280\u672f<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/17aitech.com\/?p=1469\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469\"},\"author\":{\"name\":\"Dongming\",\"@id\":\"https:\\\/\\\/17aitech.com\\\/#\\\/schema\\\/person\\\/3d23bb6f7f115fcefc9ae7803a691739\"},\"headline\":\"2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784\",\"datePublished\":\"2024-05-13T07:02:05+00:00\",\"dateModified\":\"2024-08-25T03:51:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469\"},\"wordCount\":264,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/17aitech.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/Python.jpeg\",\"keywords\":[\"Python\u57fa\u7840\"],\"articleSection\":[\"\u535a\u5ba2\u6587\u7ae0\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/17aitech.com\\\/?p=1469#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469\",\"url\":\"https:\\\/\\\/17aitech.com\\\/?p=1469\",\"name\":\"2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784 - \u4e00\u8d77AI\u6280\u672f\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/17aitech.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/17aitech.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/Python.jpeg\",\"datePublished\":\"2024-05-13T07:02:05+00:00\",\"dateModified\":\"2024-08-25T03:51:38+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/17aitech.com\\\/#\\\/schema\\\/person\\\/3d23bb6f7f115fcefc9ae7803a691739\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/17aitech.com\\\/?p=1469\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469#primaryimage\",\"url\":\"https:\\\/\\\/17aitech.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/Python.jpeg\",\"contentUrl\":\"https:\\\/\\\/17aitech.com\\\/wp-content\\\/uploads\\\/2024\\\/05\\\/Python.jpeg\",\"width\":2076,\"height\":1300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/17aitech.com\\\/?p=1469#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\\\/\\\/17aitech.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/17aitech.com\\\/#website\",\"url\":\"https:\\\/\\\/17aitech.com\\\/\",\"name\":\"\u4e00\u8d77AI\u6280\u672f\",\"description\":\"\u8ba9AI\u77e5\u8bc6\u89e6\u624b\u53ef\u53ca\",\"alternateName\":\"\u4e00\u8d77AI\u6280\u672f\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/17aitech.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/17aitech.com\\\/#\\\/schema\\\/person\\\/3d23bb6f7f115fcefc9ae7803a691739\",\"name\":\"Dongming\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"\\\/\\\/17aitech.com\\\/wp-content\\\/uploads\\\/member\\\/avatars\\\/238a0b923820dcc5.1732798681.jpg\",\"url\":\"\\\/\\\/17aitech.com\\\/wp-content\\\/uploads\\\/member\\\/avatars\\\/238a0b923820dcc5.1732798681.jpg\",\"contentUrl\":\"\\\/\\\/17aitech.com\\\/wp-content\\\/uploads\\\/member\\\/avatars\\\/238a0b923820dcc5.1732798681.jpg\",\"caption\":\"Dongming\"},\"description\":\"\u89c1\u5929\u5730\uff0c\u89c1\u4f17\u751f\uff0c\u89c1\u81ea\u5df1\u3002\",\"sameAs\":[\"http:\\\/\\\/17aitech.com\"],\"url\":\"https:\\\/\\\/17aitech.com\\\/?page_id=33738&user=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784 - \u4e00\u8d77AI\u6280\u672f","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/17aitech.com\/?p=1469","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/17aitech.com\/?p=1469#article","isPartOf":{"@id":"https:\/\/17aitech.com\/?p=1469"},"author":{"name":"Dongming","@id":"https:\/\/17aitech.com\/#\/schema\/person\/3d23bb6f7f115fcefc9ae7803a691739"},"headline":"2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784","datePublished":"2024-05-13T07:02:05+00:00","dateModified":"2024-08-25T03:51:38+00:00","mainEntityOfPage":{"@id":"https:\/\/17aitech.com\/?p=1469"},"wordCount":264,"commentCount":0,"image":{"@id":"https:\/\/17aitech.com\/?p=1469#primaryimage"},"thumbnailUrl":"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/05\/Python.jpeg","keywords":["Python\u57fa\u7840"],"articleSection":["\u535a\u5ba2\u6587\u7ae0"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/17aitech.com\/?p=1469#respond"]}]},{"@type":"WebPage","@id":"https:\/\/17aitech.com\/?p=1469","url":"https:\/\/17aitech.com\/?p=1469","name":"2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784 - \u4e00\u8d77AI\u6280\u672f","isPartOf":{"@id":"https:\/\/17aitech.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/17aitech.com\/?p=1469#primaryimage"},"image":{"@id":"https:\/\/17aitech.com\/?p=1469#primaryimage"},"thumbnailUrl":"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/05\/Python.jpeg","datePublished":"2024-05-13T07:02:05+00:00","dateModified":"2024-08-25T03:51:38+00:00","author":{"@id":"https:\/\/17aitech.com\/#\/schema\/person\/3d23bb6f7f115fcefc9ae7803a691739"},"breadcrumb":{"@id":"https:\/\/17aitech.com\/?p=1469#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/17aitech.com\/?p=1469"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/17aitech.com\/?p=1469#primaryimage","url":"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/05\/Python.jpeg","contentUrl":"https:\/\/17aitech.com\/wp-content\/uploads\/2024\/05\/Python.jpeg","width":2076,"height":1300},{"@type":"BreadcrumbList","@id":"https:\/\/17aitech.com\/?p=1469#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/17aitech.com\/"},{"@type":"ListItem","position":2,"name":"2.Python\u57fa\u672c\u6570\u636e\u7ed3\u6784"}]},{"@type":"WebSite","@id":"https:\/\/17aitech.com\/#website","url":"https:\/\/17aitech.com\/","name":"\u4e00\u8d77AI\u6280\u672f","description":"\u8ba9AI\u77e5\u8bc6\u89e6\u624b\u53ef\u53ca","alternateName":"\u4e00\u8d77AI\u6280\u672f","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/17aitech.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/17aitech.com\/#\/schema\/person\/3d23bb6f7f115fcefc9ae7803a691739","name":"Dongming","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"\/\/17aitech.com\/wp-content\/uploads\/member\/avatars\/238a0b923820dcc5.1732798681.jpg","url":"\/\/17aitech.com\/wp-content\/uploads\/member\/avatars\/238a0b923820dcc5.1732798681.jpg","contentUrl":"\/\/17aitech.com\/wp-content\/uploads\/member\/avatars\/238a0b923820dcc5.1732798681.jpg","caption":"Dongming"},"description":"\u89c1\u5929\u5730\uff0c\u89c1\u4f17\u751f\uff0c\u89c1\u81ea\u5df1\u3002","sameAs":["http:\/\/17aitech.com"],"url":"https:\/\/17aitech.com\/?page_id=33738&user=1"}]}},"_links":{"self":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts\/1469","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1469"}],"version-history":[{"count":28,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts\/1469\/revisions"}],"predecessor-version":[{"id":1497,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/posts\/1469\/revisions\/1497"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=\/wp\/v2\/media\/1638"}],"wp:attachment":[{"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/17aitech.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}