{"id":562,"date":"2025-10-23T15:01:16","date_gmt":"2025-10-23T07:01:16","guid":{"rendered":"http:\/\/www.pyteam.cn\/?p=562"},"modified":"2025-10-23T15:01:16","modified_gmt":"2025-10-23T07:01:16","slug":"python3-%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84","status":"publish","type":"post","link":"http:\/\/www.pyteam.cn\/index.php\/2025\/10\/23\/python3-%e6%95%b0%e6%8d%ae%e7%bb%93%e6%9e%84\/","title":{"rendered":"Python3 \u6570\u636e\u7ed3\u6784"},"content":{"rendered":"\n<p>\u672c\u7ae0\u8282\u6211\u4eec\u4e3b\u8981\u7ed3\u5408\u524d\u9762\u6240\u5b66\u7684\u77e5\u8bc6\u70b9\u6765\u4ecb\u7ecdPython\u6570\u636e\u7ed3\u6784\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5217\u8868<\/h2>\n\n\n\n<p>Python\u4e2d\u5217\u8868\u662f\u53ef\u53d8\u7684\uff0c\u8fd9\u662f\u5b83\u533a\u522b\u4e8e\u5b57\u7b26\u4e32\u548c\u5143\u7ec4\u7684\u6700\u91cd\u8981\u7684\u7279\u70b9\uff0c\u4e00\u53e5\u8bdd\u6982\u62ec\u5373\uff1a\u5217\u8868\u53ef\u4ee5\u4fee\u6539\uff0c\u800c\u5b57\u7b26\u4e32\u548c\u5143\u7ec4\u4e0d\u80fd\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f Python \u4e2d\u5217\u8868\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>\u65b9\u6cd5<\/th><th>\u63cf\u8ff0<\/th><\/tr><tr><td>list.append(x)<\/td><td>\u628a\u4e00\u4e2a\u5143\u7d20\u6dfb\u52a0\u5230\u5217\u8868\u7684\u7ed3\u5c3e\uff0c\u76f8\u5f53\u4e8e a[len(a):] = [x]\u3002<\/td><\/tr><tr><td>list.extend(L)<\/td><td>\u901a\u8fc7\u6dfb\u52a0\u6307\u5b9a\u5217\u8868\u7684\u6240\u6709\u5143\u7d20\u6765\u6269\u5145\u5217\u8868\uff0c\u76f8\u5f53\u4e8e a[len(a):] = L\u3002<\/td><\/tr><tr><td>list.insert(i, x)<\/td><td>\u5728\u6307\u5b9a\u4f4d\u7f6e\u63d2\u5165\u4e00\u4e2a\u5143\u7d20\u3002\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u51c6\u5907\u63d2\u5165\u5230\u5176\u524d\u9762\u7684\u90a3\u4e2a\u5143\u7d20\u7684\u7d22\u5f15\uff0c\u4f8b\u5982 a.insert(0, x) \u4f1a\u63d2\u5165\u5230\u6574\u4e2a\u5217\u8868\u4e4b\u524d\uff0c\u800c a.insert(len(a), x) \u76f8\u5f53\u4e8e a.append(x) \u3002<\/td><\/tr><tr><td>list.remove(x)<\/td><td>\u5220\u9664\u5217\u8868\u4e2d\u503c\u4e3a x \u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u3002\u5982\u679c\u6ca1\u6709\u8fd9\u6837\u7684\u5143\u7d20\uff0c\u5c31\u4f1a\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\u3002<\/td><\/tr><tr><td>list.pop([i])<\/td><td>\u4ece\u5217\u8868\u7684\u6307\u5b9a\u4f4d\u7f6e\u79fb\u9664\u5143\u7d20\uff0c\u5e76\u5c06\u5176\u8fd4\u56de\u3002\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u7d22\u5f15\uff0ca.pop()\u8fd4\u56de\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u3002\u5143\u7d20\u968f\u5373\u4ece\u5217\u8868\u4e2d\u88ab\u79fb\u9664\u3002\uff08\u65b9\u6cd5\u4e2d i \u4e24\u8fb9\u7684\u65b9\u62ec\u53f7\u8868\u793a\u8fd9\u4e2a\u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u800c\u4e0d\u662f\u8981\u6c42\u4f60\u8f93\u5165\u4e00\u5bf9\u65b9\u62ec\u53f7\uff0c\u4f60\u4f1a\u7ecf\u5e38\u5728 Python \u5e93\u53c2\u8003\u624b\u518c\u4e2d\u9047\u5230\u8fd9\u6837\u7684\u6807\u8bb0\u3002\uff09<\/td><\/tr><tr><td>list.clear()<\/td><td>\u79fb\u9664\u5217\u8868\u4e2d\u7684\u6240\u6709\u9879\uff0c\u7b49\u4e8edel a[:]\u3002<\/td><\/tr><tr><td>list.index(x)<\/td><td>\u8fd4\u56de\u5217\u8868\u4e2d\u7b2c\u4e00\u4e2a\u503c\u4e3a x \u7684\u5143\u7d20\u7684\u7d22\u5f15\u3002\u5982\u679c\u6ca1\u6709\u5339\u914d\u7684\u5143\u7d20\u5c31\u4f1a\u8fd4\u56de\u4e00\u4e2a\u9519\u8bef\u3002<\/td><\/tr><tr><td>list.count(x)<\/td><td>\u8fd4\u56de x \u5728\u5217\u8868\u4e2d\u51fa\u73b0\u7684\u6b21\u6570\u3002<\/td><\/tr><tr><td>list.sort()<\/td><td>\u5bf9\u5217\u8868\u4e2d\u7684\u5143\u7d20\u8fdb\u884c\u6392\u5e8f\u3002<\/td><\/tr><tr><td>list.reverse()<\/td><td>\u5012\u6392\u5217\u8868\u4e2d\u7684\u5143\u7d20\u3002<\/td><\/tr><tr><td>list.copy()<\/td><td>\u8fd4\u56de\u5217\u8868\u7684\u6d45\u590d\u5236\uff0c\u7b49\u4e8ea[:]\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u4e0b\u9762\u793a\u4f8b\u6f14\u793a\u4e86\u5217\u8868\u7684\u5927\u90e8\u5206\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;a&nbsp;=&nbsp;[66.25,&nbsp;333,&nbsp;333,&nbsp;1,&nbsp;1234.5]<br>&gt;&gt;&gt;&nbsp;<strong>print<\/strong>(a.count(333),&nbsp;a.count(66.25),&nbsp;a.count(&#8216;x&#8217;))<br>2&nbsp;1&nbsp;0<br>&gt;&gt;&gt;&nbsp;a.insert(2,&nbsp;-1)<br>&gt;&gt;&gt;&nbsp;a.append(333)<br>&gt;&gt;&gt;&nbsp;a<br>[66.25,&nbsp;333,&nbsp;-1,&nbsp;333,&nbsp;1,&nbsp;1234.5,&nbsp;333]<br>&gt;&gt;&gt;&nbsp;a.index(333)<br>1<br>&gt;&gt;&gt;&nbsp;a.remove(333)<br>&gt;&gt;&gt;&nbsp;a<br>[66.25,&nbsp;-1,&nbsp;333,&nbsp;1,&nbsp;1234.5,&nbsp;333]<br>&gt;&gt;&gt;&nbsp;a.reverse()<br>&gt;&gt;&gt;&nbsp;a<br>[333,&nbsp;1234.5,&nbsp;1,&nbsp;333,&nbsp;-1,&nbsp;66.25]<br>&gt;&gt;&gt;&nbsp;a.sort()<br>&gt;&gt;&gt;&nbsp;a<br>[-1,&nbsp;1,&nbsp;66.25,&nbsp;333,&nbsp;333,&nbsp;1234.5]<\/p>\n\n\n\n<p>\u6ce8\u610f\uff1a\u7c7b\u4f3c insert, remove \u6216 sort \u7b49\u4fee\u6539\u5217\u8868\u7684\u65b9\u6cd5\u6ca1\u6709\u8fd4\u56de\u503c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c06\u5217\u8868\u5f53\u505a\u6808\u4f7f\u7528<\/h2>\n\n\n\n<p>\u5728 Python \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\uff08list\uff09\u6765\u5b9e\u73b0\u6808\u7684\u529f\u80fd\u3002\u6808\u662f\u4e00\u79cd\u540e\u8fdb\u5148\u51fa\uff08LIFO, Last-In-First-Out\uff09\u6570\u636e\u7ed3\u6784\uff0c\u610f\u5473\u7740\u6700\u540e\u6dfb\u52a0\u7684\u5143\u7d20\u6700\u5148\u88ab\u79fb\u9664\u3002\u5217\u8868\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\uff0c\u4f7f\u5176\u975e\u5e38\u9002\u5408\u7528\u4e8e\u6808\u64cd\u4f5c\uff0c\u7279\u522b\u662f&nbsp;<strong>append()<\/strong>&nbsp;\u548c&nbsp;<strong>pop()<\/strong>&nbsp;\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>\u7528 append() \u65b9\u6cd5\u53ef\u4ee5\u628a\u4e00\u4e2a\u5143\u7d20\u6dfb\u52a0\u5230\u6808\u9876\uff0c\u7528\u4e0d\u6307\u5b9a\u7d22\u5f15\u7684 pop() \u65b9\u6cd5\u53ef\u4ee5\u628a\u4e00\u4e2a\u5143\u7d20\u4ece\u6808\u9876\u91ca\u653e\u51fa\u6765\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6808\u64cd\u4f5c<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u538b\u5165\uff08Push\uff09<\/strong>: \u5c06\u4e00\u4e2a\u5143\u7d20\u6dfb\u52a0\u5230\u6808\u7684\u9876\u7aef\u3002<\/li>\n\n\n\n<li><strong>\u5f39\u51fa\uff08Pop\uff09<\/strong>: \u79fb\u9664\u5e76\u8fd4\u56de\u6808\u9876\u5143\u7d20\u3002<\/li>\n\n\n\n<li><strong>\u67e5\u770b\u6808\u9876\u5143\u7d20\uff08Peek\/Top\uff09<\/strong>: \u8fd4\u56de\u6808\u9876\u5143\u7d20\u800c\u4e0d\u79fb\u9664\u5b83\u3002<\/li>\n\n\n\n<li><strong>\u68c0\u67e5\u662f\u5426\u4e3a\u7a7a\uff08IsEmpty\uff09<\/strong>: \u68c0\u67e5\u6808\u662f\u5426\u4e3a\u7a7a\u3002<\/li>\n\n\n\n<li><strong>\u83b7\u53d6\u6808\u7684\u5927\u5c0f\uff08Size\uff09<\/strong>: \u83b7\u53d6\u6808\u4e2d\u5143\u7d20\u7684\u6570\u91cf\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u5728 Python \u4e2d\u4f7f\u7528\u5217\u8868\u5b9e\u73b0\u8fd9\u4e9b\u64cd\u4f5c\u7684\u8be6\u7ec6\u8bf4\u660e\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1\u3001\u521b\u5efa\u4e00\u4e2a\u7a7a\u6808<\/h3>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>stack&nbsp;=&nbsp;[]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2\u3001\u538b\u5165\uff08Push\uff09\u64cd\u4f5c<\/h3>\n\n\n\n<p>\u4f7f\u7528 append() \u65b9\u6cd5\u5c06\u5143\u7d20\u6dfb\u52a0\u5230\u6808\u7684\u9876\u7aef\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>stack.append(1)<br>stack.append(2)<br>stack.append(3)<br><strong>print<\/strong>(stack)&nbsp;# \u8f93\u51fa: [1, 2, 3]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3\u3001\u5f39\u51fa\uff08Pop\uff09\u64cd\u4f5c<\/h3>\n\n\n\n<p>\u4f7f\u7528 pop() \u65b9\u6cd5\u79fb\u9664\u5e76\u8fd4\u56de\u6808\u9876\u5143\u7d20\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>top_element&nbsp;=&nbsp;stack.pop()<br><strong>print<\/strong>(top_element)&nbsp;# \u8f93\u51fa: 3<br><strong>print<\/strong>(stack)&nbsp;# \u8f93\u51fa: [1, 2]<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4\u3001\u67e5\u770b\u6808\u9876\u5143\u7d20\uff08Peek\/Top\uff09<\/h3>\n\n\n\n<p>\u76f4\u63a5\u8bbf\u95ee\u5217\u8868\u7684\u6700\u540e\u4e00\u4e2a\u5143\u7d20\uff08\u4e0d\u79fb\u9664\uff09\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>top_element&nbsp;=&nbsp;stack[-1]<br><strong>print<\/strong>(top_element)&nbsp;# \u8f93\u51fa: 2<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5\u3001\u68c0\u67e5\u662f\u5426\u4e3a\u7a7a\uff08IsEmpty\uff09<\/h3>\n\n\n\n<p>\u68c0\u67e5\u5217\u8868\u662f\u5426\u4e3a\u7a7a\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>is_empty&nbsp;=&nbsp;len(stack)&nbsp;==&nbsp;0<br><strong>print<\/strong>(is_empty)&nbsp;# \u8f93\u51fa: False<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6\u3001\u83b7\u53d6\u6808\u7684\u5927\u5c0f\uff08Size\uff09<\/h3>\n\n\n\n<p>\u4f7f\u7528 len() \u51fd\u6570\u83b7\u53d6\u6808\u4e2d\u5143\u7d20\u7684\u6570\u91cf\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>size&nbsp;=&nbsp;len(stack)<br><strong>print<\/strong>(size)&nbsp;# \u8f93\u51fa: 2<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u5b9e\u4f8b\uff0c\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u4e0a\u8ff0\u64cd\u4f5c\u6765\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684\u6808\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p><strong>class<\/strong>&nbsp;Stack:<br>&nbsp;<strong>def<\/strong>&nbsp;__init__(self):<br>&nbsp;self.stack&nbsp;=&nbsp;[]<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;push(self,&nbsp;item):<br>&nbsp;self.stack.append(item)<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;pop(self):<br>&nbsp;<strong>if<\/strong>&nbsp;<strong>not<\/strong>&nbsp;self.is_empty():<br>&nbsp;<strong>return<\/strong>&nbsp;self.stack.pop()<br>&nbsp;<strong>else<\/strong>:<br>&nbsp;<strong>raise<\/strong>&nbsp;IndexError(&#8220;pop from empty stack&#8221;)<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;peek(self):<br>&nbsp;<strong>if<\/strong>&nbsp;<strong>not<\/strong>&nbsp;self.is_empty():<br>&nbsp;<strong>return<\/strong>&nbsp;self.stack[-1]<br>&nbsp;<strong>else<\/strong>:<br>&nbsp;<strong>raise<\/strong>&nbsp;IndexError(&#8220;peek from empty stack&#8221;)<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;is_empty(self):<br>&nbsp;<strong>return<\/strong>&nbsp;len(self.stack)&nbsp;==&nbsp;0<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;size(self):<br>&nbsp;<strong>return<\/strong>&nbsp;len(self.stack)<\/p>\n\n\n\n<p># \u4f7f\u7528\u793a\u4f8b<br>stack&nbsp;=&nbsp;Stack()<br>stack.push(1)<br>stack.push(2)<br>stack.push(3)<\/p>\n\n\n\n<p><strong>print<\/strong>(&#8220;\u6808\u9876\u5143\u7d20:&#8221;,&nbsp;stack.peek())&nbsp;# \u8f93\u51fa: \u6808\u9876\u5143\u7d20: 3<br><strong>print<\/strong>(&#8220;\u6808\u5927\u5c0f:&#8221;,&nbsp;stack.size())&nbsp;# \u8f93\u51fa: \u6808\u5927\u5c0f: 3<\/p>\n\n\n\n<p><strong>print<\/strong>(&#8220;\u5f39\u51fa\u5143\u7d20:&#8221;,&nbsp;stack.pop())&nbsp;# \u8f93\u51fa: \u5f39\u51fa\u5143\u7d20: 3<br><strong>print<\/strong>(&#8220;\u6808\u662f\u5426\u4e3a\u7a7a:&#8221;,&nbsp;stack.is_empty())&nbsp;# \u8f93\u51fa: \u6808\u662f\u5426\u4e3a\u7a7a: False<br><strong>print<\/strong>(&#8220;\u6808\u5927\u5c0f:&#8221;,&nbsp;stack.size())&nbsp;# \u8f93\u51fa: \u6808\u5927\u5c0f: 2<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2a Stack \u7c7b\uff0c\u5c01\u88c5\u4e86\u5217\u8868\u4f5c\u4e3a\u5e95\u5c42\u6570\u636e\u7ed3\u6784\uff0c\u5e76\u5b9e\u73b0\u4e86\u6808\u7684\u57fa\u672c\u64cd\u4f5c\u3002<\/p>\n\n\n\n<p>\u8f93\u51fa\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u6808\u9876\u5143\u7d20: 3\n\u6808\u5927\u5c0f: 3\n\u5f39\u51fa\u5143\u7d20: 3\n\u6808\u662f\u5426\u4e3a\u7a7a: False\n\u6808\u5927\u5c0f: 2<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c06\u5217\u8868\u5f53\u4f5c\u961f\u5217\u4f7f\u7528<\/h2>\n\n\n\n<p>\u5728 Python \u4e2d\uff0c\u5217\u8868\uff08list\uff09\u53ef\u4ee5\u7528\u4f5c\u961f\u5217\uff08queue\uff09\uff0c\u4f46\u7531\u4e8e\u5217\u8868\u7684\u7279\u70b9\uff0c\u76f4\u63a5\u4f7f\u7528\u5217\u8868\u6765\u5b9e\u73b0\u961f\u5217\u5e76\u4e0d\u662f\u6700\u4f18\u7684\u9009\u62e9\u3002<\/p>\n\n\n\n<p>\u961f\u5217\u662f\u4e00\u79cd\u5148\u8fdb\u5148\u51fa\uff08FIFO, First-In-First-Out\uff09\u7684\u6570\u636e\u7ed3\u6784\uff0c\u610f\u5473\u7740\u6700\u65e9\u6dfb\u52a0\u7684\u5143\u7d20\u6700\u5148\u88ab\u79fb\u9664\u3002<\/p>\n\n\n\n<p>\u4f7f\u7528\u5217\u8868\u65f6\uff0c\u5982\u679c\u9891\u7e41\u5730\u5728\u5217\u8868\u7684\u5f00\u5934\u63d2\u5165\u6216\u5220\u9664\u5143\u7d20\uff0c\u6027\u80fd\u4f1a\u53d7\u5230\u5f71\u54cd\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u64cd\u4f5c\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u662f O(n)\u3002\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cPython \u63d0\u4f9b\u4e86 collections.deque\uff0c\u5b83\u662f\u53cc\u7aef\u961f\u5217\uff0c\u53ef\u4ee5\u5728\u4e24\u7aef\u9ad8\u6548\u5730\u6dfb\u52a0\u548c\u5220\u9664\u5143\u7d20\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f7f\u7528 collections.deque \u5b9e\u73b0\u961f\u5217<\/h3>\n\n\n\n<p>collections.deque \u662f Python \u6807\u51c6\u5e93\u7684\u4e00\u90e8\u5206\uff0c\u975e\u5e38\u9002\u5408\u7528\u4e8e\u5b9e\u73b0\u961f\u5217\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4f7f\u7528 deque \u5b9e\u73b0\u961f\u5217\u7684\u793a\u4f8b\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p><strong>from<\/strong>&nbsp;collections&nbsp;<strong>import<\/strong>&nbsp;deque<\/p>\n\n\n\n<p># \u521b\u5efa\u4e00\u4e2a\u7a7a\u961f\u5217<br>queue&nbsp;=&nbsp;deque()<\/p>\n\n\n\n<p># \u5411\u961f\u5c3e\u6dfb\u52a0\u5143\u7d20<br>queue.append(&#8216;a&#8217;)<br>queue.append(&#8216;b&#8217;)<br>queue.append(&#8216;c&#8217;)<\/p>\n\n\n\n<p><strong>print<\/strong>(&#8220;\u961f\u5217\u72b6\u6001:&#8221;,&nbsp;queue)&nbsp;# \u8f93\u51fa: \u961f\u5217\u72b6\u6001: deque([&#8216;a&#8217;, &#8216;b&#8217;, &#8216;c&#8217;])<\/p>\n\n\n\n<p># \u4ece\u961f\u9996\u79fb\u9664\u5143\u7d20<br>first_element&nbsp;=&nbsp;queue.popleft()<br><strong>print<\/strong>(&#8220;\u79fb\u9664\u7684\u5143\u7d20:&#8221;,&nbsp;first_element)&nbsp;# \u8f93\u51fa: \u79fb\u9664\u7684\u5143\u7d20: a<br><strong>print<\/strong>(&#8220;\u961f\u5217\u72b6\u6001:&#8221;,&nbsp;queue)&nbsp;# \u8f93\u51fa: \u961f\u5217\u72b6\u6001: deque([&#8216;b&#8217;, &#8216;c&#8217;])<\/p>\n\n\n\n<p># \u67e5\u770b\u961f\u9996\u5143\u7d20\uff08\u4e0d\u79fb\u9664\uff09<br>front_element&nbsp;=&nbsp;queue[0]<br><strong>print<\/strong>(&#8220;\u961f\u9996\u5143\u7d20:&#8221;,&nbsp;front_element)&nbsp;# \u8f93\u51fa: \u961f\u9996\u5143\u7d20: b<\/p>\n\n\n\n<p># \u68c0\u67e5\u961f\u5217\u662f\u5426\u4e3a\u7a7a<br>is_empty&nbsp;=&nbsp;len(queue)&nbsp;==&nbsp;0<br><strong>print<\/strong>(&#8220;\u961f\u5217\u662f\u5426\u4e3a\u7a7a:&#8221;,&nbsp;is_empty)&nbsp;&nbsp;# \u8f93\u51fa: \u961f\u5217\u662f\u5426\u4e3a\u7a7a: False<\/p>\n\n\n\n<p># \u83b7\u53d6\u961f\u5217\u5927\u5c0f<br>size&nbsp;=&nbsp;len(queue)<br><strong>print<\/strong>(&#8220;\u961f\u5217\u5927\u5c0f:&#8221;,&nbsp;size)&nbsp;# \u8f93\u51fa: \u961f\u5217\u5927\u5c0f: 2<br>&#8220;`<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u4f7f\u7528\u5217\u8868\u5b9e\u73b0\u961f\u5217<\/h3>\n\n\n\n<p>\u867d\u7136 deque\u66f4\u9ad8\u6548\uff0c\u4f46\u5982\u679c\u575a\u6301\u4f7f\u7528\u5217\u8868\u6765\u5b9e\u73b0\u961f\u5217\uff0c\u4e5f\u53ef\u4ee5\u8fd9\u4e48\u505a\u3002\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528\u5217\u8868\u5b9e\u73b0\u961f\u5217\u7684\u793a\u4f8b\uff1a<\/p>\n\n\n\n<p><strong>1. \u521b\u5efa\u961f\u5217<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>queue&nbsp;=&nbsp;[]<\/p>\n\n\n\n<p><strong>2. \u5411\u961f\u5c3e\u6dfb\u52a0\u5143\u7d20<\/strong><\/p>\n\n\n\n<p>\u4f7f\u7528 append() \u65b9\u6cd5\u5c06\u5143\u7d20\u6dfb\u52a0\u5230\u961f\u5c3e\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>queue.append(&#8216;a&#8217;)<br>queue.append(&#8216;b&#8217;)<br>queue.append(&#8216;c&#8217;)<br><strong>print<\/strong>(&#8220;\u961f\u5217\u72b6\u6001:&#8221;,&nbsp;queue)&nbsp;# \u8f93\u51fa: \u961f\u5217\u72b6\u6001: [&#8216;a&#8217;, &#8216;b&#8217;, &#8216;c&#8217;]<\/p>\n\n\n\n<p><strong>3. \u4ece\u961f\u9996\u79fb\u9664\u5143\u7d20<\/strong><\/p>\n\n\n\n<p>\u4f7f\u7528 pop(0) \u65b9\u6cd5\u4ece\u961f\u9996\u79fb\u9664\u5143\u7d20\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>first_element&nbsp;=&nbsp;queue.pop(0)<br><strong>print<\/strong>(&#8220;\u79fb\u9664\u7684\u5143\u7d20:&#8221;,&nbsp;first_element)&nbsp;# \u8f93\u51fa: \u79fb\u9664\u7684\u5143\u7d20: a<br><strong>print<\/strong>(&#8220;\u961f\u5217\u72b6\u6001:&#8221;,&nbsp;queue)&nbsp;# \u8f93\u51fa: \u961f\u5217\u72b6\u6001: [&#8216;b&#8217;, &#8216;c&#8217;]<\/p>\n\n\n\n<p><strong>4. \u67e5\u770b\u961f\u9996\u5143\u7d20\uff08\u4e0d\u79fb\u9664\uff09<\/strong><\/p>\n\n\n\n<p>\u76f4\u63a5\u8bbf\u95ee\u5217\u8868\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>front_element&nbsp;=&nbsp;queue[0]<br><strong>print<\/strong>(&#8220;\u961f\u9996\u5143\u7d20:&#8221;,&nbsp;front_element)&nbsp;# \u8f93\u51fa: \u961f\u9996\u5143\u7d20: b<\/p>\n\n\n\n<p><strong>5. \u68c0\u67e5\u961f\u5217\u662f\u5426\u4e3a\u7a7a<\/strong><\/p>\n\n\n\n<p>\u68c0\u67e5\u5217\u8868\u662f\u5426\u4e3a\u7a7a\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>is_empty&nbsp;=&nbsp;len(queue)&nbsp;==&nbsp;0<br><strong>print<\/strong>(&#8220;\u961f\u5217\u662f\u5426\u4e3a\u7a7a:&#8221;,&nbsp;is_empty)&nbsp;&nbsp;# \u8f93\u51fa: \u961f\u5217\u662f\u5426\u4e3a\u7a7a: False<\/p>\n\n\n\n<p><strong>6. \u83b7\u53d6\u961f\u5217\u5927\u5c0f<\/strong><\/p>\n\n\n\n<p>\u4f7f\u7528 len() \u51fd\u6570\u83b7\u53d6\u961f\u5217\u7684\u5927\u5c0f\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>size&nbsp;=&nbsp;len(queue)<br><strong>print<\/strong>(&#8220;\u961f\u5217\u5927\u5c0f:&#8221;,&nbsp;size)&nbsp;# \u8f93\u51fa: \u961f\u5217\u5927\u5c0f: 2<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b9e\u4f8b\uff08\u4f7f\u7528\u5217\u8868\u5b9e\u73b0\u961f\u5217\uff09<\/h3>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p><strong>class<\/strong>&nbsp;Queue:<br>&nbsp;<strong>def<\/strong>&nbsp;__init__(self):<br>&nbsp;self.queue&nbsp;=&nbsp;[]<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;enqueue(self,&nbsp;item):<br>&nbsp;self.queue.append(item)<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;dequeue(self):<br>&nbsp;<strong>if<\/strong>&nbsp;<strong>not<\/strong>&nbsp;self.is_empty():<br>&nbsp;<strong>return<\/strong>&nbsp;self.queue.pop(0)<br>&nbsp;<strong>else<\/strong>:<br>&nbsp;<strong>raise<\/strong>&nbsp;IndexError(&#8220;dequeue from empty queue&#8221;)<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;peek(self):<br>&nbsp;<strong>if<\/strong>&nbsp;<strong>not<\/strong>&nbsp;self.is_empty():<br>&nbsp;<strong>return<\/strong>&nbsp;self.queue[0]<br>&nbsp;<strong>else<\/strong>:<br>&nbsp;<strong>raise<\/strong>&nbsp;IndexError(&#8220;peek from empty queue&#8221;)<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;is_empty(self):<br>&nbsp;<strong>return<\/strong>&nbsp;len(self.queue)&nbsp;==&nbsp;0<\/p>\n\n\n\n<p>&nbsp;<strong>def<\/strong>&nbsp;size(self):<br>&nbsp;<strong>return<\/strong>&nbsp;len(self.queue)<\/p>\n\n\n\n<p># \u4f7f\u7528\u793a\u4f8b<br>queue&nbsp;=&nbsp;Queue()<br>queue.enqueue(&#8216;a&#8217;)<br>queue.enqueue(&#8216;b&#8217;)<br>queue.enqueue(&#8216;c&#8217;)<\/p>\n\n\n\n<p><strong>print<\/strong>(&#8220;\u961f\u9996\u5143\u7d20:&#8221;,&nbsp;queue.peek())&nbsp;# \u8f93\u51fa: \u961f\u9996\u5143\u7d20: a<br><strong>print<\/strong>(&#8220;\u961f\u5217\u5927\u5c0f:&#8221;,&nbsp;queue.size())&nbsp;# \u8f93\u51fa: \u961f\u5217\u5927\u5c0f: 3<\/p>\n\n\n\n<p><strong>print<\/strong>(&#8220;\u79fb\u9664\u7684\u5143\u7d20:&#8221;,&nbsp;queue.dequeue())&nbsp;# \u8f93\u51fa: \u79fb\u9664\u7684\u5143\u7d20: a<br><strong>print<\/strong>(&#8220;\u961f\u5217\u662f\u5426\u4e3a\u7a7a:&#8221;,&nbsp;queue.is_empty())&nbsp;# \u8f93\u51fa: \u961f\u5217\u662f\u5426\u4e3a\u7a7a: False<br><strong>print<\/strong>(&#8220;\u961f\u5217\u5927\u5c0f:&#8221;,&nbsp;queue.size())&nbsp;# \u8f93\u51fa: \u961f\u5217\u5927\u5c0f: 2<\/p>\n\n\n\n<p>\u867d\u7136\u53ef\u4ee5\u4f7f\u7528\u5217\u8868\u6765\u5b9e\u73b0\u961f\u5217\uff0c\u4f46\u4f7f\u7528 collections.deque \u4f1a\u66f4\u9ad8\u6548\u548c\u7b80\u6d01\u3002\u5b83\u63d0\u4f9b\u4e86 O(1) \u65f6\u95f4\u590d\u6742\u5ea6\u7684\u6dfb\u52a0\u548c\u5220\u9664\u64cd\u4f5c\uff0c\u975e\u5e38\u9002\u5408\u961f\u5217\u8fd9\u79cd\u6570\u636e\u7ed3\u6784\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5217\u8868\u63a8\u5bfc\u5f0f<\/h2>\n\n\n\n<p>\u5217\u8868\u63a8\u5bfc\u5f0f\u63d0\u4f9b\u4e86\u4ece\u5e8f\u5217\u521b\u5efa\u5217\u8868\u7684\u7b80\u5355\u9014\u5f84\u3002\u901a\u5e38\u5e94\u7528\u7a0b\u5e8f\u5c06\u4e00\u4e9b\u64cd\u4f5c\u5e94\u7528\u4e8e\u67d0\u4e2a\u5e8f\u5217\u7684\u6bcf\u4e2a\u5143\u7d20\uff0c\u7528\u5176\u83b7\u5f97\u7684\u7ed3\u679c\u4f5c\u4e3a\u751f\u6210\u65b0\u5217\u8868\u7684\u5143\u7d20\uff0c\u6216\u8005\u6839\u636e\u786e\u5b9a\u7684\u5224\u5b9a\u6761\u4ef6\u521b\u5efa\u5b50\u5e8f\u5217\u3002<\/p>\n\n\n\n<p>\u6bcf\u4e2a\u5217\u8868\u63a8\u5bfc\u5f0f\u90fd\u5728 for \u4e4b\u540e\u8ddf\u4e00\u4e2a\u8868\u8fbe\u5f0f\uff0c\u7136\u540e\u6709\u96f6\u5230\u591a\u4e2a for \u6216 if \u5b50\u53e5\u3002\u8fd4\u56de\u7ed3\u679c\u662f\u4e00\u4e2a\u6839\u636e\u8868\u8fbe\u4ece\u5176\u540e\u7684 for \u548c if \u4e0a\u4e0b\u6587\u73af\u5883\u4e2d\u751f\u6210\u51fa\u6765\u7684\u5217\u8868\u3002\u5982\u679c\u5e0c\u671b\u8868\u8fbe\u5f0f\u63a8\u5bfc\u51fa\u4e00\u4e2a\u5143\u7ec4\uff0c\u5c31\u5fc5\u987b\u4f7f\u7528\u62ec\u53f7\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4eec\u5c06\u5217\u8868\u4e2d\u6bcf\u4e2a\u6570\u503c\u4e58\u4e09\uff0c\u83b7\u5f97\u4e00\u4e2a\u65b0\u7684\u5217\u8868\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;vec&nbsp;=&nbsp;[2,&nbsp;4,&nbsp;6]<br>&gt;&gt;&gt;&nbsp;[3*x&nbsp;<strong>for<\/strong>&nbsp;x&nbsp;<strong>in<\/strong>&nbsp;vec]<br>[6,&nbsp;12,&nbsp;18]<\/p>\n\n\n\n<p>\u73b0\u5728\u6211\u4eec\u73a9\u4e00\u70b9\u5c0f\u82b1\u6837\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;[[x,&nbsp;x**2]&nbsp;<strong>for<\/strong>&nbsp;x&nbsp;<strong>in<\/strong>&nbsp;vec]<br>[[2,&nbsp;4],&nbsp;[4,&nbsp;16],&nbsp;[6,&nbsp;36]]<\/p>\n\n\n\n<p>\u8fd9\u91cc\u6211\u4eec\u5bf9\u5e8f\u5217\u91cc\u6bcf\u4e00\u4e2a\u5143\u7d20\u9010\u4e2a\u8c03\u7528\u67d0\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u4f8b<\/h2>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;freshfruit&nbsp;=&nbsp;[&#8216; &nbsp;banana&#8217;,&nbsp;&#8216; &nbsp;loganberry &#8216;,&nbsp;&#8216;passion fruit &nbsp;&#8216;]<br>&gt;&gt;&gt;&nbsp;[weapon.strip()&nbsp;<strong>for<\/strong>&nbsp;weapon&nbsp;<strong>in<\/strong>&nbsp;freshfruit]<br>[&#8216;banana&#8217;,&nbsp;&#8216;loganberry&#8217;,&nbsp;&#8216;passion fruit&#8217;]<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u7528 if \u5b50\u53e5\u4f5c\u4e3a\u8fc7\u6ee4\u5668\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;[3*x&nbsp;<strong>for<\/strong>&nbsp;x&nbsp;<strong>in<\/strong>&nbsp;vec&nbsp;<strong>if<\/strong>&nbsp;x&nbsp;&gt;&nbsp;3]<br>[12,&nbsp;18]<br>&gt;&gt;&gt;&nbsp;[3*x&nbsp;<strong>for<\/strong>&nbsp;x&nbsp;<strong>in<\/strong>&nbsp;vec&nbsp;<strong>if<\/strong>&nbsp;x&nbsp;&lt;&nbsp;2]<br>[]<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5173\u4e8e\u5faa\u73af\u548c\u5176\u5b83\u6280\u5de7\u7684\u6f14\u793a\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;vec1&nbsp;=&nbsp;[2,&nbsp;4,&nbsp;6]<br>&gt;&gt;&gt;&nbsp;vec2&nbsp;=&nbsp;[4,&nbsp;3,&nbsp;-9]<br>&gt;&gt;&gt;&nbsp;[x*y&nbsp;<strong>for<\/strong>&nbsp;x&nbsp;<strong>in<\/strong>&nbsp;vec1&nbsp;<strong>for<\/strong>&nbsp;y&nbsp;<strong>in<\/strong>&nbsp;vec2]<br>[8,&nbsp;6,&nbsp;-18,&nbsp;16,&nbsp;12,&nbsp;-36,&nbsp;24,&nbsp;18,&nbsp;-54]<br>&gt;&gt;&gt;&nbsp;[x+y&nbsp;<strong>for<\/strong>&nbsp;x&nbsp;<strong>in<\/strong>&nbsp;vec1&nbsp;<strong>for<\/strong>&nbsp;y&nbsp;<strong>in<\/strong>&nbsp;vec2]<br>[6,&nbsp;5,&nbsp;-7,&nbsp;8,&nbsp;7,&nbsp;-5,&nbsp;10,&nbsp;9,&nbsp;-3]<br>&gt;&gt;&gt;&nbsp;[vec1[i]*vec2[i]&nbsp;<strong>for<\/strong>&nbsp;i&nbsp;<strong>in<\/strong>&nbsp;range(len(vec1))]<br>[8,&nbsp;12,&nbsp;-54]<\/p>\n\n\n\n<p>\u5217\u8868\u63a8\u5bfc\u5f0f\u53ef\u4ee5\u4f7f\u7528\u590d\u6742\u8868\u8fbe\u5f0f\u6216\u5d4c\u5957\u51fd\u6570\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;[str(round(355\/113,&nbsp;i))&nbsp;<strong>for<\/strong>&nbsp;i&nbsp;<strong>in<\/strong>&nbsp;range(1,&nbsp;6)]<br>[&#8216;3.1&#8217;,&nbsp;&#8216;3.14&#8217;,&nbsp;&#8216;3.142&#8217;,&nbsp;&#8216;3.1416&#8217;,&nbsp;&#8216;3.14159&#8217;]<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5d4c\u5957\u5217\u8868\u89e3\u6790<\/h2>\n\n\n\n<p>Python\u7684\u5217\u8868\u8fd8\u53ef\u4ee5\u5d4c\u5957\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u5b9e\u4f8b\u5c55\u793a\u4e863X4\u7684\u77e9\u9635\u5217\u8868\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;matrix&nbsp;=&nbsp;[<br>&#8230; &nbsp; &nbsp;&nbsp;[1,&nbsp;2,&nbsp;3,&nbsp;4],<br>&#8230; &nbsp; &nbsp;&nbsp;[5,&nbsp;6,&nbsp;7,&nbsp;8],<br>&#8230; &nbsp; &nbsp;&nbsp;[9,&nbsp;10,&nbsp;11,&nbsp;12],<br>&#8230;&nbsp;]<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u5b9e\u4f8b\u5c063X4\u7684\u77e9\u9635\u5217\u8868\u8f6c\u6362\u4e3a4X3\u5217\u8868\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;[[row[i]&nbsp;<strong>for<\/strong>&nbsp;row&nbsp;<strong>in<\/strong>&nbsp;matrix]&nbsp;<strong>for<\/strong>&nbsp;i&nbsp;<strong>in<\/strong>&nbsp;range(4)]<br>[[1,&nbsp;5,&nbsp;9],&nbsp;[2,&nbsp;6,&nbsp;10],&nbsp;[3,&nbsp;7,&nbsp;11],&nbsp;[4,&nbsp;8,&nbsp;12]]<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u5b9e\u4f8b\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\u6765\u5b9e\u73b0\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;transposed&nbsp;=&nbsp;[]<br>&gt;&gt;&gt;&nbsp;<strong>for<\/strong>&nbsp;i&nbsp;<strong>in<\/strong>&nbsp;range(4):<br>&#8230; &nbsp; &nbsp;&nbsp;transposed.append([row[i]&nbsp;<strong>for<\/strong>&nbsp;row&nbsp;<strong>in<\/strong>&nbsp;matrix])<br>&#8230;<br>&gt;&gt;&gt;&nbsp;transposed<br>[[1,&nbsp;5,&nbsp;9],&nbsp;[2,&nbsp;6,&nbsp;10],&nbsp;[3,&nbsp;7,&nbsp;11],&nbsp;[4,&nbsp;8,&nbsp;12]]<\/p>\n\n\n\n<p>\u53e6\u5916\u4e00\u79cd\u5b9e\u73b0\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;transposed&nbsp;=&nbsp;[]<br>&gt;&gt;&gt;&nbsp;<strong>for<\/strong>&nbsp;i&nbsp;<strong>in<\/strong>&nbsp;range(4):<br>&#8230; &nbsp; &nbsp;&nbsp;# the following 3 lines implement the nested listcomp<br>&#8230; &nbsp; &nbsp;&nbsp;transposed_row&nbsp;=&nbsp;[]<br>&#8230; &nbsp; &nbsp;&nbsp;<strong>for<\/strong>&nbsp;row&nbsp;<strong>in<\/strong>&nbsp;matrix:<br>&#8230; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;transposed_row.append(row[i])<br>&#8230; &nbsp; &nbsp;&nbsp;transposed.append(transposed_row)<br>&#8230;<br>&gt;&gt;&gt;&nbsp;transposed<br>[[1,&nbsp;5,&nbsp;9],&nbsp;[2,&nbsp;6,&nbsp;10],&nbsp;[3,&nbsp;7,&nbsp;11],&nbsp;[4,&nbsp;8,&nbsp;12]]<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">del \u8bed\u53e5<\/h2>\n\n\n\n<p>\u4f7f\u7528 del \u8bed\u53e5\u53ef\u4ee5\u4ece\u4e00\u4e2a\u5217\u8868\u4e2d\u6839\u636e\u7d22\u5f15\u6765\u5220\u9664\u4e00\u4e2a\u5143\u7d20\uff0c\u800c\u4e0d\u662f\u503c\u6765\u5220\u9664\u5143\u7d20\u3002\u8fd9\u4e0e\u4f7f\u7528 pop() \u8fd4\u56de\u4e00\u4e2a\u503c\u4e0d\u540c\u3002\u53ef\u4ee5\u7528 del \u8bed\u53e5\u4ece\u5217\u8868\u4e2d\u5220\u9664\u4e00\u4e2a\u5207\u5272\uff0c\u6216\u6e05\u7a7a\u6574\u4e2a\u5217\u8868\uff08\u6211\u4eec\u4ee5\u524d\u4ecb\u7ecd\u7684\u65b9\u6cd5\u662f\u7ed9\u8be5\u5207\u5272\u8d4b\u4e00\u4e2a\u7a7a\u5217\u8868\uff09\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;a&nbsp;=&nbsp;[-1,&nbsp;1,&nbsp;66.25,&nbsp;333,&nbsp;333,&nbsp;1234.5]<br>&gt;&gt;&gt;&nbsp;<strong>del<\/strong>&nbsp;a[0]<br>&gt;&gt;&gt;&nbsp;a<br>[1,&nbsp;66.25,&nbsp;333,&nbsp;333,&nbsp;1234.5]<br>&gt;&gt;&gt;&nbsp;<strong>del<\/strong>&nbsp;a[2:4]<br>&gt;&gt;&gt;&nbsp;a<br>[1,&nbsp;66.25,&nbsp;1234.5]<br>&gt;&gt;&gt;&nbsp;<strong>del<\/strong>&nbsp;a[:]<br>&gt;&gt;&gt;&nbsp;a<br>[]<\/p>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u7528 del \u5220\u9664\u5b9e\u4f53\u53d8\u91cf\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&gt;&gt;&gt; del a<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5143\u7ec4\u548c\u5e8f\u5217<\/h2>\n\n\n\n<p>\u5143\u7ec4\u7531\u82e5\u5e72\u9017\u53f7\u5206\u9694\u7684\u503c\u7ec4\u6210\uff0c\u4f8b\u5982\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;t&nbsp;=&nbsp;12345,&nbsp;54321,&nbsp;&#8216;hello!&#8217;<br>&gt;&gt;&gt;&nbsp;t[0]<br>12345<br>&gt;&gt;&gt;&nbsp;t<br>(12345,&nbsp;54321,&nbsp;&#8216;hello!&#8217;)<br>&gt;&gt;&gt;&nbsp;# Tuples may be nested:<br>&#8230;&nbsp;u&nbsp;=&nbsp;t,&nbsp;(1,&nbsp;2,&nbsp;3,&nbsp;4,&nbsp;5)<br>&gt;&gt;&gt;&nbsp;u<br>((12345,&nbsp;54321,&nbsp;&#8216;hello!&#8217;),&nbsp;(1,&nbsp;2,&nbsp;3,&nbsp;4,&nbsp;5))<\/p>\n\n\n\n<p>\u5982\u4f60\u6240\u89c1\uff0c\u5143\u7ec4\u5728\u8f93\u51fa\u65f6\u603b\u662f\u6709\u62ec\u53f7\u7684\uff0c\u4ee5\u4fbf\u4e8e\u6b63\u786e\u8868\u8fbe\u5d4c\u5957\u7ed3\u6784\u3002\u5728\u8f93\u5165\u65f6\u53ef\u80fd\u6709\u6216\u6ca1\u6709\u62ec\u53f7\uff0c \u4e0d\u8fc7\u62ec\u53f7\u901a\u5e38\u662f\u5fc5\u987b\u7684\uff08\u5982\u679c\u5143\u7ec4\u662f\u66f4\u5927\u7684\u8868\u8fbe\u5f0f\u7684\u4e00\u90e8\u5206\uff09\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u96c6\u5408<\/h2>\n\n\n\n<p>\u96c6\u5408\u662f\u4e00\u4e2a\u65e0\u5e8f\u4e0d\u91cd\u590d\u5143\u7d20\u7684\u96c6\u3002\u57fa\u672c\u529f\u80fd\u5305\u62ec\u5173\u7cfb\u6d4b\u8bd5\u548c\u6d88\u9664\u91cd\u590d\u5143\u7d20\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u7528\u5927\u62ec\u53f7({})\u521b\u5efa\u96c6\u5408\u3002\u6ce8\u610f\uff1a\u5982\u679c\u8981\u521b\u5efa\u4e00\u4e2a\u7a7a\u96c6\u5408\uff0c\u4f60\u5fc5\u987b\u7528 set() \u800c\u4e0d\u662f {} \uff1b\u540e\u8005\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u5b57\u5178\uff0c\u4e0b\u4e00\u8282\u6211\u4eec\u4f1a\u4ecb\u7ecd\u8fd9\u4e2a\u6570\u636e\u7ed3\u6784\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6f14\u793a\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;basket&nbsp;=&nbsp;{&#8216;apple&#8217;,&nbsp;&#8216;orange&#8217;,&nbsp;&#8216;apple&#8217;,&nbsp;&#8216;pear&#8217;,&nbsp;&#8216;orange&#8217;,&nbsp;&#8216;banana&#8217;}<br>&gt;&gt;&gt;&nbsp;<strong>print<\/strong>(basket)&nbsp;# \u5220\u9664\u91cd\u590d\u7684<br>{&#8216;orange&#8217;,&nbsp;&#8216;banana&#8217;,&nbsp;&#8216;pear&#8217;,&nbsp;&#8216;apple&#8217;}<br>&gt;&gt;&gt;&nbsp;&#8216;orange&#8217;&nbsp;<strong>in<\/strong>&nbsp;basket &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;# \u68c0\u6d4b\u6210\u5458<br>True<br>&gt;&gt;&gt;&nbsp;&#8216;crabgrass&#8217;&nbsp;<strong>in<\/strong>&nbsp;basket<br>False<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;# \u4ee5\u4e0b\u6f14\u793a\u4e86\u4e24\u4e2a\u96c6\u5408\u7684\u64cd\u4f5c<br>&#8230;<br>&gt;&gt;&gt;&nbsp;a&nbsp;=&nbsp;set(&#8216;abracadabra&#8217;)<br>&gt;&gt;&gt;&nbsp;b&nbsp;=&nbsp;set(&#8216;alacazam&#8217;)<br>&gt;&gt;&gt;&nbsp;a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# a \u4e2d\u552f\u4e00\u7684\u5b57\u6bcd<br>{&#8216;a&#8217;,&nbsp;&#8216;r&#8217;,&nbsp;&#8216;b&#8217;,&nbsp;&#8216;c&#8217;,&nbsp;&#8216;d&#8217;}<br>&gt;&gt;&gt;&nbsp;a &#8211; b &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# \u5728 a \u4e2d\u7684\u5b57\u6bcd\uff0c\u4f46\u4e0d\u5728 b \u4e2d<br>{&#8216;r&#8217;,&nbsp;&#8216;d&#8217;,&nbsp;&#8216;b&#8217;}<br>&gt;&gt;&gt;&nbsp;a | b &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# \u5728 a \u6216 b \u4e2d\u7684\u5b57\u6bcd<br>{&#8216;a&#8217;,&nbsp;&#8216;c&#8217;,&nbsp;&#8216;r&#8217;,&nbsp;&#8216;d&#8217;,&nbsp;&#8216;b&#8217;,&nbsp;&#8216;m&#8217;,&nbsp;&#8216;z&#8217;,&nbsp;&#8216;l&#8217;}<br>&gt;&gt;&gt;&nbsp;a &amp; b &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# \u5728 a \u548c b \u4e2d\u90fd\u6709\u7684\u5b57\u6bcd<br>{&#8216;a&#8217;,&nbsp;&#8216;c&#8217;}<br>&gt;&gt;&gt;&nbsp;a ^ b &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# \u5728 a \u6216 b \u4e2d\u7684\u5b57\u6bcd\uff0c\u4f46\u4e0d\u540c\u65f6\u5728 a \u548c b \u4e2d<br>{&#8216;r&#8217;,&nbsp;&#8216;d&#8217;,&nbsp;&#8216;b&#8217;,&nbsp;&#8216;m&#8217;,&nbsp;&#8216;z&#8217;,&nbsp;&#8216;l&#8217;}<\/p>\n\n\n\n<p>\u96c6\u5408\u4e5f\u652f\u6301\u63a8\u5bfc\u5f0f\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;a&nbsp;=&nbsp;{x&nbsp;<strong>for<\/strong>&nbsp;x&nbsp;<strong>in<\/strong>&nbsp;&#8216;abracadabra&#8217;&nbsp;<strong>if<\/strong>&nbsp;x&nbsp;<strong>not<\/strong>&nbsp;<strong>in<\/strong>&nbsp;&#8216;abc&#8217;}<br>&gt;&gt;&gt;&nbsp;a<br>{&#8216;r&#8217;,&nbsp;&#8216;d&#8217;}<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b57\u5178<\/h2>\n\n\n\n<p>\u53e6\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684 Python \u5185\u5efa\u6570\u636e\u7c7b\u578b\u662f\u5b57\u5178\u3002<\/p>\n\n\n\n<p>\u5e8f\u5217\u662f\u4ee5\u8fde\u7eed\u7684\u6574\u6570\u4e3a\u7d22\u5f15\uff0c\u4e0e\u6b64\u4e0d\u540c\u7684\u662f\uff0c\u5b57\u5178\u4ee5\u5173\u952e\u5b57\u4e3a\u7d22\u5f15\uff0c\u5173\u952e\u5b57\u53ef\u4ee5\u662f\u4efb\u610f\u4e0d\u53ef\u53d8\u7c7b\u578b\uff0c\u901a\u5e38\u7528\u5b57\u7b26\u4e32\u6216\u6570\u503c\u3002<\/p>\n\n\n\n<p>\u7406\u89e3\u5b57\u5178\u7684\u6700\u4f73\u65b9\u5f0f\u662f\u628a\u5b83\u770b\u505a\u65e0\u5e8f\u7684\u952e=&gt;\u503c\u5bf9\u96c6\u5408\u3002\u5728\u540c\u4e00\u4e2a\u5b57\u5178\u4e4b\u5185\uff0c\u5173\u952e\u5b57\u5fc5\u987b\u662f\u4e92\u4e0d\u76f8\u540c\u3002<\/p>\n\n\n\n<p>\u4e00\u5bf9\u5927\u62ec\u53f7\u521b\u5efa\u4e00\u4e2a\u7a7a\u7684\u5b57\u5178\uff1a{}\u3002<\/p>\n\n\n\n<p>\u8fd9\u662f\u4e00\u4e2a\u5b57\u5178\u8fd0\u7528\u7684\u7b80\u5355\u4f8b\u5b50\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;tel&nbsp;=&nbsp;{&#8216;jack&#8217;:&nbsp;4098,&nbsp;&#8216;sape&#8217;:&nbsp;4139}<br>&gt;&gt;&gt;&nbsp;tel[&#8216;guido&#8217;]&nbsp;=&nbsp;4127<br>&gt;&gt;&gt;&nbsp;tel<br>{&#8216;sape&#8217;:&nbsp;4139,&nbsp;&#8216;guido&#8217;:&nbsp;4127,&nbsp;&#8216;jack&#8217;:&nbsp;4098}<br>&gt;&gt;&gt;&nbsp;tel[&#8216;jack&#8217;]<br>4098<br>&gt;&gt;&gt;&nbsp;<strong>del<\/strong>&nbsp;tel[&#8216;sape&#8217;]<br>&gt;&gt;&gt;&nbsp;tel[&#8216;irv&#8217;]&nbsp;=&nbsp;4127<br>&gt;&gt;&gt;&nbsp;tel<br>{&#8216;guido&#8217;:&nbsp;4127,&nbsp;&#8216;irv&#8217;:&nbsp;4127,&nbsp;&#8216;jack&#8217;:&nbsp;4098}<br>&gt;&gt;&gt;&nbsp;list(tel.keys())<br>[&#8216;irv&#8217;,&nbsp;&#8216;guido&#8217;,&nbsp;&#8216;jack&#8217;]<br>&gt;&gt;&gt;&nbsp;sorted(tel.keys())<br>[&#8216;guido&#8217;,&nbsp;&#8216;irv&#8217;,&nbsp;&#8216;jack&#8217;]<br>&gt;&gt;&gt;&nbsp;&#8216;guido&#8217;&nbsp;<strong>in<\/strong>&nbsp;tel<br>True<br>&gt;&gt;&gt;&nbsp;&#8216;jack&#8217;&nbsp;<strong>not<\/strong>&nbsp;<strong>in<\/strong>&nbsp;tel<br>False<\/p>\n\n\n\n<p>\u6784\u9020\u51fd\u6570 dict() \u76f4\u63a5\u4ece\u952e\u503c\u5bf9\u5143\u7ec4\u5217\u8868\u4e2d\u6784\u5efa\u5b57\u5178\u3002\u5982\u679c\u6709\u56fa\u5b9a\u7684\u6a21\u5f0f\uff0c\u5217\u8868\u63a8\u5bfc\u5f0f\u6307\u5b9a\u7279\u5b9a\u7684\u952e\u503c\u5bf9\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;dict([(&#8216;sape&#8217;,&nbsp;4139),&nbsp;(&#8216;guido&#8217;,&nbsp;4127),&nbsp;(&#8216;jack&#8217;,&nbsp;4098)])<br>{&#8216;sape&#8217;:&nbsp;4139,&nbsp;&#8216;jack&#8217;:&nbsp;4098,&nbsp;&#8216;guido&#8217;:&nbsp;4127}<\/p>\n\n\n\n<p>\u6b64\u5916\uff0c\u5b57\u5178\u63a8\u5bfc\u53ef\u4ee5\u7528\u6765\u521b\u5efa\u4efb\u610f\u952e\u548c\u503c\u7684\u8868\u8fbe\u5f0f\u8bcd\u5178\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;{x: x**2&nbsp;<strong>for<\/strong>&nbsp;x&nbsp;<strong>in<\/strong>&nbsp;(2,&nbsp;4,&nbsp;6)}<br>{2:&nbsp;4,&nbsp;4:&nbsp;16,&nbsp;6:&nbsp;36}<\/p>\n\n\n\n<p>\u5982\u679c\u5173\u952e\u5b57\u53ea\u662f\u7b80\u5355\u7684\u5b57\u7b26\u4e32\uff0c\u4f7f\u7528\u5173\u952e\u5b57\u53c2\u6570\u6307\u5b9a\u952e\u503c\u5bf9\u6709\u65f6\u5019\u66f4\u65b9\u4fbf\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;dict(sape=4139,&nbsp;guido=4127,&nbsp;jack=4098)<br>{&#8216;sape&#8217;:&nbsp;4139,&nbsp;&#8216;jack&#8217;:&nbsp;4098,&nbsp;&#8216;guido&#8217;:&nbsp;4127}<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u904d\u5386\u6280\u5de7<\/h2>\n\n\n\n<p>\u5728\u5b57\u5178\u4e2d\u904d\u5386\u65f6\uff0c\u5173\u952e\u5b57\u548c\u5bf9\u5e94\u7684\u503c\u53ef\u4ee5\u4f7f\u7528 items() \u65b9\u6cd5\u540c\u65f6\u89e3\u8bfb\u51fa\u6765\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;knights&nbsp;=&nbsp;{&#8216;gallahad&#8217;:&nbsp;&#8216;the pure&#8217;,&nbsp;&#8216;robin&#8217;:&nbsp;&#8216;the brave&#8217;}<br>&gt;&gt;&gt;&nbsp;<strong>for<\/strong>&nbsp;k,&nbsp;v&nbsp;<strong>in<\/strong>&nbsp;knights.items():<br>&#8230; &nbsp; &nbsp;&nbsp;<strong>print<\/strong>(k,&nbsp;v)<br>&#8230;<br>gallahad&nbsp;the pure<br>robin the brave<\/p>\n\n\n\n<p>\u5728\u5e8f\u5217\u4e2d\u904d\u5386\u65f6\uff0c\u7d22\u5f15\u4f4d\u7f6e\u548c\u5bf9\u5e94\u503c\u53ef\u4ee5\u4f7f\u7528 enumerate() \u51fd\u6570\u540c\u65f6\u5f97\u5230\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;<strong>for<\/strong>&nbsp;i,&nbsp;v&nbsp;<strong>in<\/strong>&nbsp;enumerate([&#8216;tic&#8217;,&nbsp;&#8216;tac&#8217;,&nbsp;&#8216;toe&#8217;]):<br>&#8230; &nbsp; &nbsp;&nbsp;<strong>print<\/strong>(i,&nbsp;v)<br>&#8230;<br>0&nbsp;tic<br>1&nbsp;tac<br>2&nbsp;toe<\/p>\n\n\n\n<p>\u540c\u65f6\u904d\u5386\u4e24\u4e2a\u6216\u66f4\u591a\u7684\u5e8f\u5217\uff0c\u53ef\u4ee5\u4f7f\u7528 zip() \u7ec4\u5408\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;questions&nbsp;=&nbsp;[&#8216;name&#8217;,&nbsp;&#8216;quest&#8217;,&nbsp;&#8216;favorite color&#8217;]<br>&gt;&gt;&gt;&nbsp;answers&nbsp;=&nbsp;[&#8216;lancelot&#8217;,&nbsp;&#8216;the holy grail&#8217;,&nbsp;&#8216;blue&#8217;]<br>&gt;&gt;&gt;&nbsp;<strong>for<\/strong>&nbsp;q,&nbsp;a&nbsp;<strong>in<\/strong>&nbsp;zip(questions,&nbsp;answers):<br>&#8230; &nbsp; &nbsp;&nbsp;<strong>print<\/strong>(&#8216;What is your {0}? &nbsp;It is {1}.&#8217;.format(q,&nbsp;a))<br>&#8230;<br>What&nbsp;<strong>is<\/strong>&nbsp;your name? &nbsp;It&nbsp;<strong>is<\/strong>&nbsp;lancelot.<br>What&nbsp;<strong>is<\/strong>&nbsp;your quest? &nbsp;It&nbsp;<strong>is<\/strong>&nbsp;the holy grail.<br>What&nbsp;<strong>is<\/strong>&nbsp;your favorite color? &nbsp;It&nbsp;<strong>is<\/strong>&nbsp;blue.<\/p>\n\n\n\n<p>\u8981\u53cd\u5411\u904d\u5386\u4e00\u4e2a\u5e8f\u5217\uff0c\u9996\u5148\u6307\u5b9a\u8fd9\u4e2a\u5e8f\u5217\uff0c\u7136\u540e\u8c03\u7528 reversed() \u51fd\u6570\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;<strong>for<\/strong>&nbsp;i&nbsp;<strong>in<\/strong>&nbsp;reversed(range(1,&nbsp;10,&nbsp;2)):<br>&#8230; &nbsp; &nbsp;&nbsp;<strong>print<\/strong>(i)<br>&#8230;<br>9<br>7<br>5<br>3<br>1<\/p>\n\n\n\n<p>\u8981\u6309\u987a\u5e8f\u904d\u5386\u4e00\u4e2a\u5e8f\u5217\uff0c\u4f7f\u7528 sorted() \u51fd\u6570\u8fd4\u56de\u4e00\u4e2a\u5df2\u6392\u5e8f\u7684\u5e8f\u5217\uff0c\u5e76\u4e0d\u4fee\u6539\u539f\u503c\uff1a<\/p>\n\n\n\n<p>&gt;&gt;&gt;&nbsp;basket&nbsp;=&nbsp;[&#8216;apple&#8217;,&nbsp;&#8216;orange&#8217;,&nbsp;&#8216;apple&#8217;,&nbsp;&#8216;pear&#8217;,&nbsp;&#8216;orange&#8217;,&nbsp;&#8216;banana&#8217;]<br>&gt;&gt;&gt;&nbsp;<strong>for<\/strong>&nbsp;f&nbsp;<strong>in<\/strong>&nbsp;sorted(set(basket)):<br>&#8230; &nbsp; &nbsp;&nbsp;<strong>print<\/strong>(f)<br>&#8230;<br>apple<br>banana<br>orange<br>pear<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u7ae0\u8282\u6211\u4eec\u4e3b\u8981\u7ed3\u5408\u524d\u9762\u6240\u5b66\u7684\u77e5\u8bc6\u70b9\u6765\u4ecb\u7ecdPython\u6570\u636e\u7ed3\u6784\u3002 \u5217\u8868&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":491,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-562","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-1"],"views":173,"_links":{"self":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/562","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/comments?post=562"}],"version-history":[{"count":1,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/562\/revisions"}],"predecessor-version":[{"id":563,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/posts\/562\/revisions\/563"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media\/491"}],"wp:attachment":[{"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/media?parent=562"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/categories?post=562"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.pyteam.cn\/index.php\/wp-json\/wp\/v2\/tags?post=562"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}