{"id":1034947,"date":"2024-12-31T11:54:37","date_gmt":"2024-12-31T03:54:37","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1034947.html"},"modified":"2024-12-31T11:54:39","modified_gmt":"2024-12-31T03:54:39","slug":"python%e9%87%8c%e5%a6%82%e4%bd%95%e5%ae%9a%e4%b9%89%e4%b8%80%e4%b8%aa%e5%8f%98%e9%87%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1034947.html","title":{"rendered":"python\u91cc\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/6eb050e1-fdc7-4af6-95ed-b96f2d05a6d2.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u91cc\u5982\u4f55\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u4e3b\u8981\u5305\u62ec\uff1a\u76f4\u63a5\u8d4b\u503c\u3001\u4f7f\u7528\u8fd0\u7b97\u7b26\u3001\u901a\u8fc7\u8f93\u5165\u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7b49\u3002<\/strong> \u5176\u4e2d\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u662f\u901a\u8fc7\u76f4\u63a5\u8d4b\u503c\u6765\u5b9a\u4e49\u53d8\u91cf\uff0c\u4f8b\u5982\uff1a<code>x = 10<\/code>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u5728Python\u4e2d\u5b9a\u4e49\u548c\u4f7f\u7528\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u53d8\u91cf\u7684\u5b9a\u4e49<\/h3>\n<\/p>\n<p><h4>1\u3001\u76f4\u63a5\u8d4b\u503c<\/h4>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u53d8\u91cf\u7684\u5b9a\u4e49\u975e\u5e38\u7b80\u5355\uff0c\u53ef\u4ee5\u901a\u8fc7\u76f4\u63a5\u8d4b\u503c\u6765\u5b8c\u6210\u3002\u76f4\u63a5\u8d4b\u503c\u662f\u6307\u5c06\u4e00\u4e2a\u503c\u8d4b\u7ed9\u53d8\u91cf\u540d\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">x = 10<\/p>\n<p>name = &quot;Alice&quot;<\/p>\n<p>is_student = True<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e9b\u4f8b\u5b50\u4e2d\uff0c<code>x<\/code> \u662f\u4e00\u4e2a\u6574\u6570\u7c7b\u578b\u7684\u53d8\u91cf\uff0c<code>name<\/code> \u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u53d8\u91cf\uff0c<code>is_student<\/code> \u662f\u4e00\u4e2a\u5e03\u5c14\u7c7b\u578b\u7684\u53d8\u91cf\u3002<strong>Python\u662f\u4e00\u79cd\u52a8\u6001\u7c7b\u578b\u7684\u8bed\u8a00\uff0c\u8fd9\u610f\u5473\u7740\u4f60\u4e0d\u9700\u8981\u63d0\u524d\u58f0\u660e\u53d8\u91cf\u7684\u7c7b\u578b\uff0cPython\u4f1a\u6839\u636e\u8d4b\u503c\u81ea\u52a8\u8bc6\u522b\u53d8\u91cf\u7684\u7c7b\u578b\u3002<\/strong><\/p>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528\u8fd0\u7b97\u7b26<\/h4>\n<\/p>\n<p><p>\u4f60\u8fd8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u8fd0\u7b97\u7b26\u6765\u5b9a\u4e49\u53d8\u91cf\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u901a\u8fc7\u7b80\u5355\u7684\u6570\u5b66\u8fd0\u7b97\u6765\u5b9a\u4e49\u53d8\u91cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">a = 5<\/p>\n<p>b = 10<\/p>\n<p>c = a + b  # c\u73b0\u5728\u7684\u503c\u662f15<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>a<\/code> \u548c <code>b<\/code> \u90fd\u662f\u6574\u6570\u7c7b\u578b\u7684\u53d8\u91cf\uff0c<code>c<\/code> \u662f\u901a\u8fc7\u5c06 <code>a<\/code> \u548c <code>b<\/code> \u76f8\u52a0\u540e\u5f97\u5230\u7684\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u901a\u8fc7\u8f93\u5165\u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165<\/h4>\n<\/p>\n<p><p>Python\u8fd8\u5141\u8bb8\u4f60\u901a\u8fc7\u8f93\u5165\u51fd\u6570 <code>input()<\/code> \u6765\u83b7\u53d6\u7528\u6237\u7684\u8f93\u5165\uff0c\u5e76\u5c06\u5176\u8d4b\u7ed9\u53d8\u91cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">user_name = input(&quot;Enter your name: &quot;)<\/p>\n<p>age = int(input(&quot;Enter your age: &quot;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>user_name<\/code> \u662f\u4e00\u4e2a\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u53d8\u91cf\uff0c<code>age<\/code> \u662f\u4e00\u4e2a\u6574\u6570\u7c7b\u578b\u7684\u53d8\u91cf\u3002<strong>\u6ce8\u610f\uff1a<code>input()<\/code> \u51fd\u6570\u9ed8\u8ba4\u8fd4\u56de\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5982\u679c\u9700\u8981\u5176\u4ed6\u7c7b\u578b\u7684\u6570\u636e\uff0c\u4f60\u9700\u8981\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\u3002<\/strong><\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u53d8\u91cf\u7684\u547d\u540d\u89c4\u5219<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u53d8\u91cf\u7684\u547d\u540d\u6709\u4e00\u5b9a\u7684\u89c4\u5219\u548c\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5408\u6cd5\u5b57\u7b26<\/h4>\n<\/p>\n<p><p>\u53d8\u91cf\u540d\u53ef\u4ee5\u5305\u542b\u5b57\u6bcd\uff08\u5927\u5199\u6216\u5c0f\u5199\uff09\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf <code>_<\/code>\uff0c\u4f46\u4e0d\u80fd\u4ee5\u6570\u5b57\u5f00\u5934\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">valid_name = &quot;John&quot;<\/p>\n<p>_valid_name = &quot;John&quot;<\/p>\n<p>valid_name_2 = &quot;John&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u90fd\u662f\u5408\u6cd5\u7684\u53d8\u91cf\u540d\uff0c\u4f46\u4ee5\u4e0b\u53d8\u91cf\u540d\u662f\u4e0d\u5408\u6cd5\u7684\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">2invalid_name = &quot;John&quot;  # \u53d8\u91cf\u540d\u4e0d\u80fd\u4ee5\u6570\u5b57\u5f00\u5934<\/p>\n<p>invalid-name = &quot;John&quot;   # \u53d8\u91cf\u540d\u4e0d\u80fd\u5305\u542b\u8fde\u5b57\u7b26<\/p>\n<p>invalid name = &quot;John&quot;   # \u53d8\u91cf\u540d\u4e0d\u80fd\u5305\u542b\u7a7a\u683c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u533a\u5206\u5927\u5c0f\u5199<\/h4>\n<\/p>\n<p><p>Python\u4e2d\u7684\u53d8\u91cf\u540d\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\uff0c\u8fd9\u610f\u5473\u7740 <code>Name<\/code> \u548c <code>name<\/code> \u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u53d8\u91cf\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">name = &quot;Alice&quot;<\/p>\n<p>Name = &quot;Bob&quot;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>name<\/code> \u548c <code>Name<\/code> \u662f\u4e24\u4e2a\u4e0d\u540c\u7684\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u907f\u514d\u4f7f\u7528\u4fdd\u7559\u5b57<\/h4>\n<\/p>\n<p><p>Python\u6709\u4e00\u4e9b\u4fdd\u7559\u5b57\uff08\u5173\u952e\u5b57\uff09\uff0c\u8fd9\u4e9b\u4fdd\u7559\u5b57\u5728Python\u4e2d\u6709\u7279\u6b8a\u7684\u610f\u4e49\uff0c\u4e0d\u80fd\u7528\u4f5c\u53d8\u91cf\u540d\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class = &quot;Math&quot;  # \u9519\u8bef\uff0cclass\u662fPython\u7684\u4fdd\u7559\u5b57<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528 <code>keyword<\/code> \u6a21\u5757\u6765\u67e5\u770bPython\u4e2d\u7684\u6240\u6709\u4fdd\u7559\u5b57\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import keyword<\/p>\n<p>print(keyword.kwlist)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u53d8\u91cf\u7684\u4f5c\u7528\u57df<\/h3>\n<\/p>\n<p><p>\u53d8\u91cf\u7684\u4f5c\u7528\u57df\u662f\u6307\u53d8\u91cf\u5728\u7a0b\u5e8f\u4e2d\u53ef\u4ee5\u8bbf\u95ee\u7684\u8303\u56f4\u3002\u5728Python\u4e2d\uff0c\u53d8\u91cf\u7684\u4f5c\u7528\u57df\u53ef\u4ee5\u662f\u5c40\u90e8\u7684\uff08local\uff09\u3001\u5168\u5c40\u7684\uff08global\uff09\u6216\u8005\u662f\u5d4c\u5957\u7684\uff08enclosed\uff09\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u5c40\u90e8\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5c40\u90e8\u53d8\u91cf\u662f\u5728\u51fd\u6570\u5185\u90e8\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u5176\u4f5c\u7528\u57df\u4ec5\u9650\u4e8e\u51fd\u6570\u5185\u90e8\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def my_function():<\/p>\n<p>    x = 10  # x\u662f\u4e00\u4e2a\u5c40\u90e8\u53d8\u91cf<\/p>\n<p>    print(x)<\/p>\n<p>my_function()<\/p>\n<p>print(x)  # \u9519\u8bef\uff0cx\u5728\u51fd\u6570\u5916\u662f\u4e0d\u53ef\u8bbf\u95ee\u7684<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>x<\/code> \u662f\u4e00\u4e2a\u5c40\u90e8\u53d8\u91cf\uff0c\u5176\u4f5c\u7528\u57df\u4ec5\u9650\u4e8e <code>my_function<\/code> \u51fd\u6570\u5185\u90e8\u3002<\/p>\n<\/p>\n<p><h4>2\u3001\u5168\u5c40\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5168\u5c40\u53d8\u91cf\u662f\u5728\u51fd\u6570\u5916\u90e8\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u5176\u4f5c\u7528\u57df\u662f\u6574\u4e2a\u7a0b\u5e8f\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">x = 10  # x\u662f\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf<\/p>\n<p>def my_function():<\/p>\n<p>    print(x)  # \u53ef\u4ee5\u5728\u51fd\u6570\u5185\u90e8\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf<\/p>\n<p>my_function()<\/p>\n<p>print(x)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>x<\/code> \u662f\u4e00\u4e2a\u5168\u5c40\u53d8\u91cf\uff0c\u53ef\u4ee5\u5728 <code>my_function<\/code> \u51fd\u6570\u5185\u90e8\u548c\u5916\u90e8\u8bbf\u95ee\u3002<\/p>\n<\/p>\n<p><h4>3\u3001\u5d4c\u5957\u53d8\u91cf<\/h4>\n<\/p>\n<p><p>\u5d4c\u5957\u53d8\u91cf\u662f\u5728\u5d4c\u5957\u51fd\u6570\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\uff0c\u5176\u4f5c\u7528\u57df\u4ec5\u9650\u4e8e\u5d4c\u5957\u51fd\u6570\u53ca\u5176\u5185\u90e8\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def outer_function():<\/p>\n<p>    x = 10  # x\u662f\u5916\u90e8\u51fd\u6570\u7684\u5c40\u90e8\u53d8\u91cf<\/p>\n<p>    def inner_function():<\/p>\n<p>        print(x)  # \u53ef\u4ee5\u5728\u5185\u90e8\u51fd\u6570\u4e2d\u8bbf\u95ee\u5916\u90e8\u51fd\u6570\u7684\u5c40\u90e8\u53d8\u91cf<\/p>\n<p>    inner_function()<\/p>\n<p>outer_function()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c<code>x<\/code> \u662f\u5916\u90e8\u51fd\u6570 <code>outer_function<\/code> \u7684\u5c40\u90e8\u53d8\u91cf\uff0c\u4f46\u53ef\u4ee5\u5728\u5185\u90e8\u51fd\u6570 <code>inner_function<\/code> \u4e2d\u8bbf\u95ee\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u53d8\u91cf\u7684\u7c7b\u578b\u8f6c\u6362<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5185\u7f6e\u51fd\u6570\u6765\u8f6c\u6362\u53d8\u91cf\u7684\u7c7b\u578b\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">x = &quot;10&quot;<\/p>\n<p>y = int(x)  # \u5c06\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u53d8\u91cfx\u8f6c\u6362\u4e3a\u6574\u6570\u7c7b\u578b<\/p>\n<p>z = 3.14<\/p>\n<p>w = str(z)  # \u5c06\u6d6e\u70b9\u6570\u7c7b\u578b\u7684\u53d8\u91cfz\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32\u7c7b\u578b<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5e38\u89c1\u7684\u7c7b\u578b\u8f6c\u6362\u51fd\u6570\u5305\u62ec <code>int()<\/code>\u3001<code>float()<\/code>\u3001<code>str()<\/code>\u3001<code>bool()<\/code> \u7b49\u3002<\/p>\n<\/p>\n<p><h3>\u4e94\u3001\u53d8\u91cf\u7684\u547d\u540d\u60ef\u4f8b<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u6709\u4e00\u4e9b\u53d8\u91cf\u7684\u547d\u540d\u60ef\u4f8b\uff0c\u8fd9\u4e9b\u60ef\u4f8b\u6709\u52a9\u4e8e\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<p><h4>1\u3001\u4f7f\u7528\u5c0f\u5199\u5b57\u6bcd\u548c\u4e0b\u5212\u7ebf<\/h4>\n<\/p>\n<p><p>\u901a\u5e38\uff0c\u53d8\u91cf\u540d\u4f7f\u7528\u5c0f\u5199\u5b57\u6bcd\u548c\u4e0b\u5212\u7ebf <code>_<\/code> \u8fdb\u884c\u5206\u9694\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">user_name = &quot;Alice&quot;<\/p>\n<p>user_age = 25<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>2\u3001\u4f7f\u7528\u9a7c\u5cf0\u547d\u540d\u6cd5<\/h4>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u7279\u522b\u662f\u5f53\u53d8\u91cf\u540d\u8f83\u957f\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u9a7c\u5cf0\u547d\u540d\u6cd5\uff08camelCase\uff09\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">userName = &quot;Alice&quot;<\/p>\n<p>userAge = 25<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h4>3\u3001\u4f7f\u7528\u5168\u5927\u5199\u5b57\u6bcd\u8868\u793a\u5e38\u91cf<\/h4>\n<\/p>\n<p><p>\u5e38\u91cf\u662f\u6307\u5728\u7a0b\u5e8f\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u4e0d\u5e94\u6539\u53d8\u7684\u53d8\u91cf\uff0c\u901a\u5e38\u4f7f\u7528\u5168\u5927\u5199\u5b57\u6bcd\u8868\u793a\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">PI = 3.14159<\/p>\n<p>MAX_USERS = 100<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5728Python\u4e2d\u5b9a\u4e49\u53d8\u91cf\u975e\u5e38\u7b80\u5355\uff0c\u901a\u8fc7\u76f4\u63a5\u8d4b\u503c\u3001\u4f7f\u7528\u8fd0\u7b97\u7b26\u3001\u901a\u8fc7\u8f93\u5165\u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7b49\u65b9\u5f0f\u90fd\u53ef\u4ee5\u5b9a\u4e49\u53d8\u91cf\u3002\u53d8\u91cf\u7684\u547d\u540d\u6709\u4e00\u5b9a\u7684\u89c4\u5219\u548c\u6700\u4f73\u5b9e\u8df5\uff0c\u9075\u5faa\u8fd9\u4e9b\u89c4\u5219\u548c\u60ef\u4f8b\u6709\u52a9\u4e8e\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002\u7406\u89e3\u53d8\u91cf\u7684\u4f5c\u7528\u57df\u548c\u7c7b\u578b\u8f6c\u6362\u4e5f\u975e\u5e38\u91cd\u8981\uff0c\u8fd9\u6709\u52a9\u4e8e\u7f16\u5199\u66f4\u5065\u58ee\u548c\u9ad8\u6548\u7684\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p>\u603b\u4e4b\uff0c\u638c\u63e1\u53d8\u91cf\u7684\u5b9a\u4e49\u548c\u4f7f\u7528\u662f\u5b66\u4e60Python\u7f16\u7a0b\u7684\u57fa\u7840\uff0c\u901a\u8fc7\u4e0d\u65ad\u7ec3\u4e60\u548c\u5e94\u7528\uff0c\u4f60\u4f1a\u8d8a\u6765\u8d8a\u719f\u7ec3\u5730\u4f7f\u7528\u53d8\u91cf\u6765\u89e3\u51b3\u5404\u79cd\u7f16\u7a0b\u95ee\u9898\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b9a\u4e49\u53d8\u91cf\u7684\u57fa\u672c\u8bed\u6cd5\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u5b9a\u4e49\u53d8\u91cf\u7684\u57fa\u672c\u8bed\u6cd5\u975e\u5e38\u7b80\u5355\u3002\u53ea\u9700\u9009\u62e9\u4e00\u4e2a\u6709\u6548\u7684\u53d8\u91cf\u540d\uff0c\u5e76\u4f7f\u7528\u8d4b\u503c\u8fd0\u7b97\u7b26\u201c=\u201d\u5c06\u5176\u4e0e\u4e00\u4e2a\u503c\u5173\u8054\u3002\u4f8b\u5982\uff0c<code>my_variable = 10<\/code>\u5c06\u6574\u657010\u8d4b\u503c\u7ed9\u53d8\u91cf<code>my_variable<\/code>\u3002\u53d8\u91cf\u540d\u53ef\u4ee5\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u548c\u4e0b\u5212\u7ebf\uff0c\u4f46\u4e0d\u80fd\u4ee5\u6570\u5b57\u5f00\u5934\u3002<\/p>\n<p><strong>Python\u53d8\u91cf\u7684\u547d\u540d\u89c4\u5219\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53d8\u91cf\u7684\u547d\u540d\u89c4\u5219\u5305\u62ec\uff1a\u53d8\u91cf\u540d\u5fc5\u987b\u4ee5\u5b57\u6bcd\u6216\u4e0b\u5212\u7ebf\u5f00\u5934\uff0c\u540e\u9762\u53ef\u4ee5\u8ddf\u5b57\u6bcd\u3001\u6570\u5b57\u6216\u4e0b\u5212\u7ebf\u3002\u53d8\u91cf\u540d\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\uff0c\u56e0\u6b64<code>myVariable<\/code>\u548c<code>myvariable<\/code>\u88ab\u89c6\u4e3a\u4e24\u4e2a\u4e0d\u540c\u7684\u53d8\u91cf\u3002\u6b64\u5916\uff0c\u907f\u514d\u4f7f\u7528Python\u7684\u4fdd\u7559\u5b57\uff08\u5982<code>if<\/code>\u3001<code>for<\/code>\u3001<code>while<\/code>\u7b49\uff09\u4f5c\u4e3a\u53d8\u91cf\u540d\uff0c\u4ee5\u514d\u5f15\u8d77\u8bed\u6cd5\u9519\u8bef\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5b9a\u4e49\u591a\u4e2a\u53d8\u91cf\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u9017\u53f7\u5206\u9694\u7684\u65b9\u5f0f\u5728\u4e00\u884c\u4e2d\u5b9a\u4e49\u591a\u4e2a\u53d8\u91cf\u3002\u4f8b\u5982\uff0c<code>a, b, c = 1, 2, 3<\/code>\u5c061\u30012\u548c3\u5206\u522b\u8d4b\u503c\u7ed9\u53d8\u91cf<code>a<\/code>\u3001<code>b<\/code>\u548c<code>c<\/code>\u3002\u6b64\u5916\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u76f8\u540c\u7684\u503c\u4e3a\u591a\u4e2a\u53d8\u91cf\u8d4b\u503c\uff0c\u4f8b\u5982<code>x = y = z = 0<\/code>\uff0c\u8fd9\u5c060\u8d4b\u503c\u7ed9<code>x<\/code>\u3001<code>y<\/code>\u548c<code>z<\/code>\u4e09\u4e2a\u53d8\u91cf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u4e3b\u8981\u5305\u62ec\uff1a\u76f4\u63a5\u8d4b\u503c\u3001\u4f7f\u7528\u8fd0\u7b97\u7b26\u3001\u901a\u8fc7\u8f93\u5165\u51fd\u6570\u83b7\u53d6\u7528\u6237\u8f93\u5165\u7b49\u3002 \u5176\u4e2d\u6700 [&hellip;]","protected":false},"author":3,"featured_media":1034953,"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\/1034947"}],"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=1034947"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1034947\/revisions"}],"predecessor-version":[{"id":1034957,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1034947\/revisions\/1034957"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1034953"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1034947"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1034947"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1034947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}