{"id":1574,"date":"2023-02-07T00:20:14","date_gmt":"2023-02-06T16:20:14","guid":{"rendered":"http:\/\/zhang.mba\/?p=1574"},"modified":"2023-02-07T00:22:00","modified_gmt":"2023-02-06T16:22:00","slug":"python-zhong-jiao-huan-liang-ge-bian-liang-zhi","status":"publish","type":"post","link":"https:\/\/zhang.mba\/index.php\/2023\/02\/07\/00\/20\/14\/1574\/python-zhong-jiao-huan-liang-ge-bian-liang-zhi\/python\/zhangzhiqi\/","title":{"rendered":"Python \u4e2d\u4ea4\u6362\u4e24\u4e2a\u53d8\u91cf\u503c"},"content":{"rendered":"<p>\u5728 Python \u4e2d\u4ea4\u6362\u4e24\u4e2a\u53d8\u91cf\u503c\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5176\u4e2d\u4e00\u79cd\u662f\u4f7f\u7528\u4e34\u65f6\u53d8\u91cf\uff1a<\/p>\n<pre><code class=\"language-Python\">a = 5\nb = 10\n\n# Using a temporary variable\n# \u4f7f\u7528\u4e34\u65f6\u53d8\u91cf\ntemp = a\na = b\nb = temp\n\nprint(&quot;a =&quot;, a)\nprint(&quot;b =&quot;, b)\n<\/code><\/pre>\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528 Python \u7684\u8bed\u6cd5\u7cd6\uff0c\u5373\u5143\u7ec4\u89e3\u5305\uff1a<\/p>\n<pre><code class=\"language-Python\">a = 5\nb = 10\n\n# Using tuple unpacking\n# \u4f7f\u7528\u5143\u7ec4\u89e3\u5305\na, b = b, a\n\nprint(&quot;a =&quot;, a)\nprint(&quot;b =&quot;, b)\n<\/code><\/pre>\n<p>\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u8fd0\u7b97\u7b26\uff08\u4f8b\u5982\u52a0\u6cd5\u548c\u51cf\u6cd5\uff09\u8fdb\u884c\u4ea4\u6362\uff1a<\/p>\n<pre><code class=\"language-Python\">a = 5\nb = 10\n\n# Using arithmetic operators\n# \u4f7f\u7528\u8fd0\u7b97\u7b26\na = a + b\nb = a - b\na = a - b\n\nprint(&quot;a =&quot;, a)\nprint(&quot;b =&quot;, b)\n<\/code><\/pre>\n<p>\u9009\u62e9\u4ea4\u6362\u4e24\u4e2a\u53d8\u91cf\u503c\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u60a8\u7684\u9700\u6c42\u548c\u504f\u597d\u3002<\/p>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>\u5728 Python \u4e2d\u4ea4\u6362\u4e24\u4e2a\u53d8\u91cf\u503c\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5176\u4e2d\u4e00\u79cd\u662f\u4f7f\u7528\u4e34\u65f6\u53d8\u91cf\uff1a a = 5 b = 10 # Using a temporary variable # \u4f7f\u7528\u4e34\u65f6\u53d8\u91cf temp = a a = b b = temp print(&quot;a =&quot;, a) print(&quot;b =&quot;, b) \u4e5f\u53ef\u4ee5\u4f7f\u7528 Python \u7684\u8bed\u6cd5\u7cd6\uff0c\u5373\u5143\u7ec4\u89e3 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts\/1574"}],"collection":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/comments?post=1574"}],"version-history":[{"count":0,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/posts\/1574\/revisions"}],"wp:attachment":[{"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/media?parent=1574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/categories?post=1574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhang.mba\/index.php\/wp-json\/wp\/v2\/tags?post=1574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}