{"id":172493,"date":"2023-04-15T22:22:09","date_gmt":"2023-04-15T14:22:09","guid":{"rendered":"http:\/\/www.idc.net\/help\/172493\/"},"modified":"2023-04-15T22:22:09","modified_gmt":"2023-04-15T14:22:09","slug":"%e5%90%8e%e6%b5%aa%e4%ba%91python%e6%95%99%e7%a8%8b%ef%bc%9a%e5%a6%82%e4%bd%95%e8%b0%83%e7%94%a8%e4%bb%a3%e7%a0%81%e5%9c%a8python3%e4%b8%ad%e6%94%b9%e5%8f%98%e5%87%bd%e6%95%b0%e5%80%bc","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/172493\/","title":{"rendered":"\u540e\u6d6a\u4e91Python\u6559\u7a0b\uff1a\u5982\u4f55\u8c03\u7528\u4ee3\u7801\u5728python3\u4e2d\u6539\u53d8\u51fd\u6570\u503c?"},"content":{"rendered":"<p style=\"text-align:center\"><span style=\"font-size: 14px\"><img decoding=\"async\" src=\"https:\/\/oss.py.cn\/pycn\/upload\/image\/793\/343\/253\/1606817696975821.png\" class=\"aligncenter\"><\/span><\/p>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 16px\">\u63d0\u5230\u51fd\u6570\u503c\uff0c\u5c31\u79bb\u4e0d\u5f00\u5bf9\u4e8e\u53d8\u91cf\u7684\u8ba8\u8bba\uff0c\u56e0\u4e3a\u6211\u4eec\u6539\u53d8\u503c\u5c31\u4f1a\u5f15\u8d77\u53d8\u91cf\u7684\u4ea7\u751f\u3002\u653e\u5728\u4ee5\u524d\u6211\u4eec\u6240\u5b66\u7684\u51fd\u6570\u4e2d\uff0c\u6539\u53d8\u521d\u59cb\u7684\u503c\u7ecf\u8fc7\u51fd\u6570\u8fd0\u7b97\u7ed3\u679c\u53d1\u751f\u4e86\u6539\u53d8\uff0c\u8fd9\u5c31\u662f\u5c0f\u7f16\u5bf9\u4e8e\u53d8\u91cf\u7684\u4e00\u4e2a\u7406\u89e3\uff0c\u653e\u5728python\u4e2d\u540c\u6837\u9002\u7528\uff0c\u73b0\u5728\u8fd9\u4e48\u8bf4\u5f88\u591a\u5c0f\u4f19\u4f34\u5c31\u53ef\u4ee5\u7406\u89e3\u4e86\u3002\u4e0b\u9762\u6211\u4eec\u5c31\u8c03\u7528\u4ee3\u7801\u5728python3\u4e2d\u6539\u53d8\u51fd\u6570\u503c\u7684\u65b9\u6cd5\u7ed9\u5927\u5bb6\u8fdb\u884c\u5206\u4eab\u3002<\/span><\/p>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 14px\"><br \/><\/span><\/p>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 14px\">\u4ea4\u6362\u503c<\/span><\/p>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 14px\">\u4e0d\u9700\u8981\u989d\u5916\u7684\u64cd\u4f5c\u5c31\u80fd\u4ea4\u6362\u4e24\u4e2a\u53d8\u91cf\u7684\u503c\u3002<\/span><\/p>\n<pre>def&nbsp;swap(a,&nbsp;b):\n&nbsp;&nbsp;return&nbsp;b,&nbsp;a\n&nbsp;\na,&nbsp;b&nbsp;=&nbsp;-1,&nbsp;14\nswap(a,&nbsp;b)&nbsp;#&nbsp;(14,&nbsp;-1)\nspread([1,2,3,[4,5,6],[7],8,9])&nbsp;#&nbsp;[1,2,3,4,5,6,7,8,9]<\/pre>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 14px\"><\/span><\/p>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 14px\">\u5b57\u5178\u9ed8\u8ba4\u503c<br \/><\/span><\/p>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 14px\"><span style=\"font-size: 14px;font-family: \u5fae\u8f6f\u96c5\u9ed1\">\u901a\u8fc7<\/span> Key \u53d6\u5bf9\u5e94\u7684 Value \u503c\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8bbe\u7f6e\u9ed8\u8ba4\u503c\u3002\u5982\u679c get() \u65b9\u6cd5\u6ca1\u6709\u8bbe\u7f6e\u9ed8\u8ba4\u503c\uff0c\u90a3\u4e48\u5982\u679c\u9047\u5230\u4e0d\u5b58\u5728\u7684 Key\uff0c\u5219\u4f1a\u8fd4\u56de None\u3002<\/span><\/p>\n<pre>d&nbsp;=&nbsp;{'a':&nbsp;1,&nbsp;'b':&nbsp;2}\n&nbsp;\nprint(d.get('c',&nbsp;3))&nbsp;#&nbsp;3<\/pre>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 14px\"><\/span><\/p>\n<p style=\"line-height: 1.75em\"><span style=\"font-size: 16px\">\u4ee5\u4e0a\u5c31\u662fpython\u4e2d\u4e0d\u540c\u51fd\u6570\u8fdb\u884c\u53d8\u91cf\u540e\u6240\u8981\u6539\u53d8\u7684\u503c\uff0c\u4eca\u5929\u5c31\u4ea4\u6362\u503c\u548c\u5b57\u5178\u9ed8\u8ba4\u503c\u7ed9\u5927\u5bb6\u5e26\u6765\u5206\u4eab\uff0c\u6709\u9700\u8981\u7684\u5c0f\u4f19\u4f34\u4e5f\u53ef\u4ee5\u4fdd\u5b58\u4e0b\u6765\u65b9\u4fbf\u4e0b\u6b21\u7684\u56de\u987e\u5b66\u4e60\u3002<span>\u66f4\u591aPython\u5b66\u4e60\u6307\u8def:<\/span><\/span><span style=\"font-size: 16px\">PyThon\u5b66\u4e60\u7f51\u6559\u5b66\u4e2d\u5fc3<\/span><span style=\"font-size: 16px\">\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63d0\u5230\u51fd\u6570\u503c\uff0c\u5c31\u79bb\u4e0d\u5f00\u5bf9\u4e8e\u53d8\u91cf\u7684\u8ba8\u8bba\uff0c\u56e0\u4e3a\u6211\u4eec\u6539\u53d8\u503c\u5c31\u4f1a\u5f15\u8d77\u53d8\u91cf\u7684\u4ea7\u751f\u3002\u653e\u5728\u4ee5\u524d\u6211\u4eec\u6240\u5b66\u7684\u51fd\u6570\u4e2d\uff0c\u6539\u53d8\u521d\u59cb\u7684\u503c\u7ecf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":172494,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[182397],"tags":[],"class_list":["post-172493","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/172493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=172493"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/172493\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media\/172494"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=172493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=172493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=172493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}