{"id":88880,"date":"2026-08-01T21:25:08","date_gmt":"2026-08-01T13:25:08","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/88880.html"},"modified":"2026-08-01T21:25:08","modified_gmt":"2026-08-01T13:25:08","slug":"python2-%e5%b7%b2%e7%bb%88%e7%bb%93%ef%bc%8c%e5%85%a5%e6%89%8bpython-3%ef%bc%8c%e4%bd%a0%e9%9c%80%e8%a6%81%e8%bf%9930%e4%b8%aa%e6%8a%80%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/88880.html","title":{"rendered":"Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7"},"content":{"rendered":"<p>\u3002<\/p>\n<p>\u5b58\u5728\u7740\u4e00\u9879\u5177\u5907\u6548\u7528\u7684\u529f\u80fd, \u6b64\u529f\u80fd\u4e43\u662f\u53bb\u8c03\u53d6\u5148\u524d\u7684\u547d\u4ee4\u8f93\u51fa, \u5728\u8fd9\u91cc, \u8f93\u5165\u4ee5\u53ca\u8f93\u51fa\u4e8b\u5b9e\u4e0a\u5747\u4e3a\u5bf9\u8c61, \u4e3e\u4f8b\u800c\u8a00, \u4f60\u80fd\u591f\u8fd0\u7528Out\u53bb\u8c03\u53d6\u7b2c\u4e09\u6761\u547d\u4ee4\u7684\u8f93\u51fa\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u7528\u4e0b\u9762\u8fd9\u6761\u547d\u4ee4\u5b89\u88c5 &#xff1a;<\/p>\n<p>pip3<\/p>\n<p>4. \u5217\u8868\u8868\u8fbe\u5f0f<\/p>\n<p>\u4e00\u65e6\u62e5\u6709\u5217\u8868\u8868\u8fbe\u5f0f, \u4f60\u4fbf\u65e0\u9700\u518d\u501f\u52a9for loop\u53bb\u751f\u6210\u4e00\u4e2alist\u4e86, \u5176\u57fa\u672c\u8bed\u6cd5\u662f\u5982\u6b64\u8fd9\u822c:<\/p>\n<p>for item in list if<\/p>\n<p>\u8fd9\u5c31\u662f\u4e00\u4e2a\u751f\u6210\u5305\u542b\u4e00\u4e32\u6570\u5b57\u7684 list \u7684\u7b80\u5355\u4f8b\u5b50\u3002<\/p>\n<p><img decoding=\"async\" alt=\"Python\u6280\u5de7_IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132504-6a6df3b0cd7fa.jpg\" \/><\/p>\n<p>\u4e8e\u8fd9\u6761\u547d\u4ee4\u5f53\u4e2d, \u662f\u80fd\u591f\u8fd0\u7528\u8868\u8fbe\u5f0f&#xff08;&#xff09;\u7684, \u56e0\u800c\u4e5f\u80fd\u591f\u5f00\u5c55\u4e00\u4e9b\u6570\u5b66\u8fd0\u7b97:<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_Python\u6280\u5de7_IPython\u9b54\u6cd5\u51fd\u6570\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132504-6a6df3b0e8ec7.jpg\" \/><\/p>\n<p>\u4f60\u751a\u81f3\u53ef\u4ee5\u8c03\u7528\u4e00\u4e2a\u5916\u90e8\u51fd\u6570&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132505-6a6df3b10f98e.jpg\" \/><\/p>\n<p>\u6700\u540e, \u4f60\u540c\u6837\u80fd\u591f\u4e8e\u751f\u6210 list \u7684\u65f6\u5019, \u8fd0\u7528 if \u8bed\u53e5\u6765\u5c55\u5f00\u7b5b\u9009\u3002\u5728\u4e0b\u9762\u7684\u8fd9\u4e2a\u4f8b\u5b50\u4e4b\u4e2d, \u6211\u4eec\u4ec5\u4ec5\u7559\u5b58\u4e86\u80fd\u591f\u88ab 2 \u6574\u9664\u7684\u90a3\u4e9b\u503c:<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132505-6a6df3b12b540.jpg\" \/><\/p>\n<p>5. \u68c0\u67e5\u4f60\u7684\u5bf9\u8c61\u5360\u7528\u4e86\u591a\u5c11\u5185\u5b58<\/p>\n<p>\u4f60\u80fd\u591f\u8fd0\u7528sys.()\u53bb\u5bdf\u770b\u4f60\u6240\u521b\u5efa\u7684\u5bf9\u8c61\u5360\u636e\u7684\u5185\u5b58\u5927\u5c0f:<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c_Python\u6280\u5de7\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132505-6a6df3b141083.jpg\" \/><\/p>\n<p>\u54c7&#xff0c;\u7b49\u4e00\u4e0b&#xff0c;\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u5927\u7684 list \u53ea\u6709 48 \u5b57\u8282?<\/p>\n<p>\u90a3\u662f\u7531\u4e8erange\u51fd\u6570\u5355\u5355\u8fd4\u56de\u4e86\u4e00\u4e2a\u597d\u4f3clist\u7684\u7c7b\u3002\u4ece\u8fd9\u91cc\u80fd\u591f\u770b\u51fa, \u8ddf\u76f4\u63a5\u8fd0\u7528list\u76f8\u6bd4\u8f83\u800c\u8a00, \u8fd0\u7528range\u80fd\u591f\u7701\u4e0b\u597d\u591a\u7a7a\u95f4:<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132505-6a6df3b15ac8f.jpg\" \/><\/p>\n<p>6. \u8fd4\u56de\u591a\u4e2a\u503c<\/p>\n<p>\u51fd\u6570\u80fd\u591f\u540c\u65f6\u8fd4\u56de\u591a\u4e2a\u503c, \u4e14\u5e76\u4e0d\u9700\u8981\u8fd0\u7528, \u5982\u540c list \u6216\u8005\u7c7b\u8fd9\u822c\u7684\u6570\u636e\u7ed3\u6784\u3002\u5176\u5de5\u4f5c\u7684\u8fd0\u4f5c\u673a\u5236\u662f\u5982\u6b64\u8fd9\u822c\u7684\u3002<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132505-6a6df3b1740a8.jpg\" \/><\/p>\n<p>\u5f53\u8fd4\u56de\u503c\u7684\u6570\u91cf\u6781\u4e3a\u6709\u9650\u7684\u65f6\u5019, \u91c7\u7528\u8fd9\u79cd\u65b9\u5f0f\u662f\u53ef\u884c\u7684, \u7136\u800c\u4e00\u65e6\u8fd4\u56de\u503c\u7684\u6570\u91cf\u8d85\u51fa\u4e86 3 \u4e2a, \u90a3\u4e48\u8fd9\u4e9b\u8fd4\u56de\u503c\u5c31\u5e94\u5f53\u88ab\u653e\u7f6e\u5230\u4e00\u4e2a&#xff08;\u6570\u636e&#xff09;\u7c7b\u5f53\u4e2d\u4e86\u3002<\/p>\n<p>7. \u4f7f\u7528\u6570\u636e\u7c7b<\/p>\n<p>3.7\u8d77\u5f00\u59cb\u7ed9\u51fa\u6570\u636e\u7c7b\u529f\u7528, \u8be5\u529f\u7528\u548c\u5e38\u89c4\u7684\u7c7b, \u8fd8\u6709\u522b\u7684\u5982\u8fd4\u56de\u591a\u4e2a\u503c\u7684\u51fd\u6570\u7b49\u7c7b\u4f3c\u529f\u7528\u6bd4\u8d77\u6765, \u5177\u5907\u4ee5\u4e0b\u4f18\u70b9:<\/p>\n<p>\u6570\u636e\u7c7b\u578b\u6709\u6700\u4f4e\u4ee3\u7801\u91cf\u8981\u6c42<\/p>\n<p>\u56e0\u4e3a\u6570\u636e\u7c7b\u5df2\u7ecf\u81ea\u5e26\u4e86\u529f\u80fd&#xff0c;\u6545\u800c\u4f60\u53ef\u4ee5\u76f4\u63a5\u8fdb\u884c\u6570\u636e\u7c7b\u7684\u5bf9\u6bd4<\/p>\n<p>\u6570\u636e\u7c7b\u81ea\u5e26&#xff0c;\u4f60\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5728 debug \u65f6\u6253\u5370\u51fa\u4e00\u4e2a\u6570\u636e\u7c7b<\/p>\n<p>\u6570\u636e\u7c7b\u578b\u9700\u8981\u4f60\u8f93\u5165\u63d0\u793a&#xff0c;\u8fd9\u6837 bug \u91cf\u4f1a\u5927\u5927\u51cf\u5c11<\/p>\n<p>\u4e0b\u9762\u5c55\u793a\u4e86\u4e00\u4e2a\u5b9e\u7528\u7684\u6570\u636e\u7c7b\u4f8b\u5b50&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132505-6a6df3b18f9b9.jpg\" \/><\/p>\n<p>\u60f3\u66f4\u6df1\u5165\u7684\u4e86\u89e3\u6570\u636e\u7c7b&#xff0c;\u53ef\u4ee5\u53c2\u8003&#xff1a;<\/p>\n<p>8. \u5728\u4f4d\u7f6e\u4e0d\u53d8\u7684\u60c5\u51b5\u4e0b\u4ea4\u6362\u53d8\u91cf<\/p>\n<p>\u4e00\u4e2a\u5c0f\u6280\u5de7\u5c31\u53ef\u4ee5\u51cf\u5c11\u5f88\u591a\u884c\u4ee3\u7801&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132505-6a6df3b1c9808.jpg\" \/><\/p>\n<p>9. \u5408\u5e76 &#xff08; 3.5&#043;&#xff09;<\/p>\n<p>\u4ece 3.5 \u5f00\u59cb&#xff0c; \u7684\u5408\u5e76\u53d8\u5f97\u66f4\u5bb9\u6613\u4e86&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132505-6a6df3b1e7f01.jpg\" \/><\/p>\n<p>\u82e5\u662f\u5b58\u5728\u6709\u91cd\u590d\u7684 key, \u90a3\u4e48\u9996\u4e2a\u8bcd\u5178\u7684\u6b64 key \u6240\u5bf9\u5e94\u7684\u90a3\u4e2a\u503c\u5c06\u4f1a\u88ab\u8986\u76d6\u6389\u3002<\/p>\n<p>10. \u628a\u5b57\u7b26\u4e32\u53d8\u6210\u6807\u9898\u5f62\u5f0f<\/p>\n<p>\u8fd9\u53ea\u662f \u4e2d\u7684\u5b9d\u85cf\u4e4b\u4e00&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c_Python\u6280\u5de7\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132506-6a6df3b20d03e.jpg\" \/><\/p>\n<p>11. \u628a\u5b57\u7b26\u4e32\u5206\u5272\u6210 list<\/p>\n<p>\u4f60\u80fd\u591f\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u5212\u5206\u6210\u4e00\u4e2a list \u7684\u5b57\u7b26\u4e32\u3002\u5728\u4e0b\u9762\u7684\u793a\u4f8b\u91cc, \u6211\u4eec\u662f\u4ee5\u7a7a\u683c\u6765\u5212\u5206\u5b57\u7b26\u4e32\u7684:<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132506-6a6df3b22255f.jpg\" \/><\/p>\n<p>12. \u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u5217\u8868\u53d8\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32<\/p>\n<p>\u53cd\u5411\u4e0a\u4e00\u4e2a\u5c0f\u6280\u5de7, \u6211\u4eec\u80fd\u591f\u5c06\u4e00\u4e2a list \u53d8\u6210\u5b57\u7b26\u4e32\u505a\u6cd5\u4e14\u53ef\u4ee5\u5728\u6bcf\u4e2a\u8bcd\u4e2d\u95f4\u63d2\u5165\u7a7a\u683c:<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132506-6a6df3b23a3be.jpg\" \/><\/p>\n<p>\u4f60\u53ef\u80fd\u5728\u60f3\u4e3a\u4ec0\u4e48\u4e0d\u7528<\/p>\n<p>.join(&#034; &#034;)<\/p>\n<p>\u597d\u95ee\u9898&#xff01;<\/p>\n<p>\u8fd9\u662f\u7531\u4e8e, .join()\u662f\u80fd\u591f\u8fde\u63a5\u4efb\u4f55\u53ef\u8fed\u4ee3\u5bf9\u8c61\u7684, \u5e76\u975e\u4ec5\u4ec5\u5c40\u9650\u4e8e\u5217\u8868\u3002\u4e8e\u5176\u4e2d\u8fd0\u7528\u6b64\u7c7b\u51fd\u6570, \u80fd\u591f\u9632\u6b62\u90a3\u4e9b\u64cd\u4f5c, \u5728\u6211\u4eec\u6240\u4e0d\u613f\u610f\u5b83\u53d1\u751f\u7684\u5730\u65b9\u51fa\u73b0\u3002<\/p>\n<p>13. Emoji<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132506-6a6df3b252131.jpg\" \/><\/p>\n<p>\u6709\u4e9b\u4eba\u5bf9\u8fd9\u4e2a\u529f\u80fd\u6000\u6709\u559c\u597d, \u6709\u4e9b\u4eba\u5374\u5bf9\u5176\u6781\u4e3a\u6297\u62d2, \u8fd9\u56e0\u4e2a\u4f53\u4e0d\u540c\u800c\u5b58\u5728\u5dee\u5f02\u3002\u4ece\u4e25\u683c\u610f\u4e49\u6765\u8bb2, \u8fd9\u4e2a\u529f\u80fd\u7a81\u51fa\u7684\u76ca\u5904\u662f\u5f53\u5f00\u5c55\u793e\u4ea4\u6570\u636e\u5256\u6790\u4e4b\u9645\u80fd\u66f4\u4e3a\u4fbf\u5229\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u4f60\u8981\u5b89\u88c5 emoji \u6a21\u5757&#xff1a;<\/p>\n<p>pip3 emoji<\/p>\n<p>\u5b89\u88c5\u5b8c\u540e&#xff0c;\u4f60\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u4f7f\u7528\u8fd9\u4e2a\u6a21\u5757&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"Python\u6280\u5de7_IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132506-6a6df3b28f6c7.jpg\" \/><\/p>\n<p>\u60f3\u8981\u66f4\u6df1\u5165\u7684\u4e86\u89e3 emoji \u6a21\u5757&#xff0c;\u53ef\u4ee5\u53c2\u8003&#xff1a;\u3002<\/p>\n<p>14. list \u5207\u7247<\/p>\n<p>list \u5207\u7247\u7684\u57fa\u672c\u4f7f\u7528\u5f62\u5f0f\u5982\u4e0b&#xff1a;<\/p>\n<p>start:stop:step<\/p>\n<p>\u5f00\u59cb, \u505c\u6b62\u4e0e\u6b65\u9aa4, \u5747\u4e3a\u53ef\u9009\u53c2\u6570\u3002\u8bbe\u82e5\u4f60\u672a\u4f5c\u5b9a\u4e49, \u90a3\u4e48\u5b83\u4eec\u5c06\u4f9d\u636e\u5982\u4e0b\u89c4\u5219\u6765\u5206\u914d\u9ed8\u8ba4\u503c:<\/p>\n<p>start &#061; 0<\/p>\n<p>end &#061; \u65b9\u62ec\u53f7\u91cc\u9762\u5b57\u7b26\u4e32\u7684\u6700\u540e\u4e00\u4e2a\u5b57\u7b26<\/p>\n<p>step &#061; 1<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132506-6a6df3b2b12b5.jpg\" \/><\/p>\n<p>15. \u7ffb\u8f6c\u5b57\u7b26\u4e32\u548c list<\/p>\n<p>\u901a\u8fc7\u8fd0\u7528\u65b9\u624d\u6240\u63d0\u53ca\u7684\u5207\u7247\u64cd\u4f5c, \u80fd\u591f\u5b9e\u73b0\u5bf9\u5b57\u7b26\u4e32\u4ee5\u53ca list \u7684\u7ffb\u8f6c\u3002\u4e00\u65e6\u5c06 step \u8bbe\u7f6e\u4e3a -1\u8be5\u9879\u53c2\u6570, \u90a3\u4e48\u4fbf\u80fd\u591f\u8fbe\u6210\u7ffb\u8f6c\u64cd\u4f5c\u4e86\u3002<\/p>\n<p><img decoding=\"async\" alt=\"Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132506-6a6df3b2cecd9.jpg\" \/><\/p>\n<p>16. \u5c55\u793a\u5c0f\u732b\u7684\u56fe\u7247<\/p>\n<p>\u6700\u7ec8, \u6211\u8fd8\u662f\u53d1\u89c9\u5230\u4e86\u4e00\u4e2a\u80fd\u591f\u5728\u6211\u7684\u6587\u7ae0\u91cc\u63d0\u53ca\u5c0f\u732b\u7684\u5951\u673a&#xff01;\u5f53\u7136, \u4f60\u4e5f\u6709\u6216\u8bb8\u662f\u8fd0\u7528\u8fd9\u4e2a\u529f\u80fd\u53bb\u5c55\u73b0\u522b\u7684\u56fe\u3002\u9996\u5148, \u4f60\u5f97\u8fdb\u884c\u5b89\u88c5, \u8fd9\u53ef\u662fImage\u5e93\u7684\u4e00\u4e2a\u5206\u652f:<\/p>\n<p>pip3<\/p>\n<p>\u73b0\u5728\u628a\u8fd9\u4e2a\u56fe\u50cf\u4e0b\u8f7d\u4e0b\u6765\u5e76\u547d\u540d\u4e3a .jpg:<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c_Python\u6280\u5de7\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132506-6a6df3b2ec65c.jpg\" \/><\/p>\n<p>\u56fe\u6e90&#xff1a; \u7684<\/p>\n<p>\u4f60\u53ef\u7528\u4e0b\u9762\u8fd9\u6bb5 \u4ee3\u7801\u6765\u663e\u793a\u56fe\u50cf\u3002<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_Python\u6280\u5de7_IPython\u9b54\u6cd5\u51fd\u6570\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132507-6a6df3b306ecc.jpg\" \/><\/p>\n<p>\u6216\u8005\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728 \u4e0a\u505a\u8fd9\u4ef6\u4e8b\u3002<\/p>\n<p>\u80fd\u505a\u5230\u7684\u53ef\u4e0d\u5355\u5355\u53ea\u662f\u8fd9\u4e9b, \u5b83\u80fd\u591f\u5bf9\u56fe\u7247\u5f00\u5c55\u5206\u6790, \u8fdb\u884c\u88c1\u526a, \u5b9e\u65bd\u8fc7\u6ee4, \u4e88\u4ee5\u589e\u5f3a, \u52a0\u4ee5\u53d8\u5f62\u7b49\u7b49\u4e3e\u63aa\u3002\u8981\u662f\u60f3\u8981\u83b7\u53d6\u66f4\u6df1\u5ea6\u7684\u4e86\u89e3, \u90a3\u5c31\u53ef\u4ee5\u53bb\u67e5\u770b\u4e00\u4e0b\u5b83\u7684\u6587\u6863:<\/p>\n<p>17. \u4f7f\u7528 map()<\/p>\n<p>\u7684\u5185\u7f6e\u51fd\u6570\u4e4b\u4e00\u5c31\u662f map()\u3002map() \u7684\u8bed\u6cd5\u5982\u4e0b&#xff1a;<\/p>\n<p>\u56e0\u800c\u4f60\u80fd\u591f\u4e3a\u5176\u8d4b\u4e88\u4e00\u4e2a\u51fd\u6570\u7528\u4ee5\u4f7f\u5176\u5f97\u4ee5\u6267\u884c, \u63a5\u7740\u8fd8\u5f97\u4f20\u9012\u7ed9\u5b83\u76f8\u5e94\u7684\u53c2\u6570\u3002\u6b64\u53c2\u6570\u80fd\u591f\u662f\u4efb\u4e00\u53ef\u8fdb\u884c\u8fed\u4ee3\u7684\u5bf9\u8c61\u3002\u5728\u4e0b\u9762\u6240\u5217\u4e3e\u7684\u4f8b\u5b50\u5f53\u4e2d\u6211\u8fd0\u7528\u4e86 list:<\/p>\n<p><img decoding=\"async\" alt=\"Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132507-6a6df3b3221e6.jpg\" \/><\/p>\n<p>\u9a6c\u4e0a\u53bb\u7785\u7785\u4f60\u7684\u4ee3\u7801, \u6709\u6ca1\u6709\u67d0\u4e9b\u5730\u65b9\u80fd\u591f\u7528map()\u66ff\u4ee3loop\u5462&#xff01;<\/p>\n<p>18. \u4ece list \u6216\u662f \u4e2d\u83b7\u53d6 \u5143\u7d20<\/p>\n<p>\u4f60\u80fd\u591f\u901a\u8fc7set()\u53bb\u5f97\u5230list\u6216\u8005\u50cf\u7c7b\u4f3clist\u7684\u5bf9\u8c61\u7684\u5143\u7d20, \u800c\u5176\u7ed3\u679c\u4f1a\u5f52\u6765\u6210\u4e3a\u4e00\u4e2aset\u3002<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7\" src=\"2026-08-01qkpzdxizjor.png\" \/><\/p>\n<p>19. \u627e\u5230\u9ad8\u9891\u503c<\/p>\n<p>\u5728 list \u6216\u5b57\u7b26\u521b\u4e2d\u83b7\u53d6\u9ad8\u9891\u503c&#xff1a;<\/p>\n<p>max() \u6240\u5f97\u51fa\u540e\u8fd4\u56de\u4e4b\u4e3e, \u4e43\u662f\u6e90\u4e8e list \u4e4b\u4e2d\u7684\u6700\u9ad8\u503c\u3002\u800c key \u6240\u80fd\u51ed\u501f\u7684\u4e00\u79cd\u8f93\u5165\u60c5\u51b5, \u5c31\u50cf\u4e8e\u672c\u4f8b\u4e4b\u4e2d\u7684 test.count \u8fd9\u79cd, \u80fd\u591f\u7528\u4ee5\u786e\u5b9a\u4f60\u9488\u5bf9\u6392\u5e8f\u6240\u9009\u53d6\u4e4b\u884c\u5f84\u65b9\u5f0f\u3002\u6b64\u51fd\u6570\u5c06\u4f1a\u88ab\u5b9e\u7528\u81f3\u6392\u5728\u524d\u9762\u53ef\u8fdb\u884c\u8fed\u4ee3\u4e4b\u5bf9\u8c61\u6240\u5177\u5907\u7684\u6bcf\u4e00\u9879\u5440\u3002<\/p>\n<p>list \u7684\u5185\u7f6e\u51fd\u6570\u5e76\u975e test.count, \u800c\u662f\u53e6\u6709\u5176\u540d\u3002\u5f53\u6211\u4eec\u7ed9\u4e88\u67d0\u4e2a\u8f93\u5165\u65f6, test.count \u8fd9\u4e2a\u51fd\u6570\u4f1a\u9488\u5bf9\u8be5\u8f93\u5165\u8fdb\u884c\u51fa\u73b0\u6b21\u6570\u7684\u7edf\u8ba1\u3002\u82e5\u8f93\u5165\u4e3a 1, test.count(1) \u5c06\u8fd4\u56de 2&#xff0c;\u82e5\u8f93\u5165\u662f 4, test.count(4) \u5219\u4f1a\u8fd4\u56de 4\u3002<\/p>\n<p>\u8bbe\u5b9a&#xff08;\u6d4b\u8bd5\u9879\u76ee&#xff09;, \u5c06\u4f1a\u8fd4\u56de\u6570\u503c, \u4ea6\u5373\u662f: \u542b\u67091, 2, 3, 4\u8fd9\u51e0\u4e2a\u6570\u4e14\u7528\u9017\u53f7\u9694\u5f00\u7684\u96c6\u5408\u5f62\u5f0f\u6240\u4ee3\u8868\u7684\u503c\u3002<\/p>\n<p>\u8fd9\u4e48\u4e00\u6765&#xff0c;\u8fd9\u4e00\u884c\u4ee3\u7801\u65bd\u884c\u7684\u884c\u4e3a\u4fbf\u662f, \u9996\u5148\u5bfb\u89c5\u51fa\u6240\u6709\u7684 \u503c&#xff08;{1, 2, 3, 4}&#xff09;, \u800c\u540e, max \u4f1a\u9488\u5bf9\u8fd9\u56db\u4e2a\u503c\u9010\u4e2a\u5f00\u5c55 list.count \u64cd\u4f5c, \u5e76\u4e14\u8fd4\u56de\u5176\u4e2d\u6700\u5927\u7684\u503c\u3002<\/p>\n<p>20. \u521b\u5efa\u8fdb\u5ea6\u6761<\/p>\n<p>\u4f60\u80fd\u591f\u521b\u7acb\u5c5e\u4e8e\u4f60\u81ea\u8eab\u7684\u8fdb\u5ea6\u6761, \u8fd9\u540c\u6837\u662f\u9887\u5177\u8da3\u5473\u7684\u3002\u4e0d\u8fc7\u5f84\u76f4\u8fd0\u7528\u90a3\u4e2a\u5305\u5c06\u4f1a\u5feb\u51fa\u8bb8\u591a:<\/p>\n<p>pip3<\/p>\n<p>\u73b0\u5728\u4f60\u53ef\u4ee5\u6beb\u4e0d\u8d39\u529b\u7684\u521b\u5efa\u4e00\u4e2a\u8fdb\u5ea6\u6761\u4e86&#xff1a;<\/p>\n<p><img decoding=\"async\" alt=\"Python\u6280\u5de7_IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c\" src=\"2026-08-01ng20glfxd4j.png\" \/><\/p>\n<p>\u4e0b\u9762\u8fd9\u4e2a\u52a8\u753b\u5c55\u793a\u4e86\u6240\u6709\u53ef\u80fd\u7684\u8fdb\u5ea6\u6761\u7c7b\u578b&#xff1a;<\/p>\n<p>\u56fe\u6e90&#xff1a; ,<\/p>\n<p>21. \u5728\u4ea4\u4e92 shell \u4e2d\u4f7f\u7528\u300c_\u300d<\/p>\n<p>\u4f60\u53ef\u4ee5\u7528\u4e0b\u5212\u7ebf\u6765\u83b7\u5f97\u4e0a\u4e00\u6761\u547d\u4ee4\u7684\u8f93\u5165&#xff0c;\u5728 \u4e2d\u662f\u8fd9\u6837\u7684&#xff1a;<\/p>\n<p>In : 3 * 3<\/p>\n<p>Out: 9In : _ &#043; 3<\/p>\n<p>Out: 12<\/p>\n<p>\u5728shell\u91cc, \u8fd9\u6761\u547d\u4ee4\u540c\u6837\u80fd\u591f\u8fd0\u7528\u3002\u4f4d\u4e8eshell\u4e4b\u4e2d, \u4f60\u4e5f\u80fd\u591f\u501f\u7531Out\u83b7\u53d6In\u7684\u8f93\u51fa\u7ed3\u679c\u3002\u4e3e\u4f8b\u6765\u8bb2, \u4e8e\u4e0a\u9762\u6240\u4e3e\u7684\u4f8b\u5b50\u5f53\u4e2d, Out\u5c06\u4f1a\u8fd4\u56de9\u3002<\/p>\n<p>22. \u5feb\u901f\u521b\u5efa\u4e00\u4e2a\u7f51\u9875\u670d\u52a1\u5668<\/p>\n<p>\u4f60\u53ef\u4ee5\u5feb\u901f\u521b\u5efa\u4e00\u4e2a\u7f51\u9875\u670d\u52a1\u5668&#xff0c;\u5e76\u5c06\u5f53\u524d\u7684\u8def\u5f84\u4f5c\u4e3a\u5185\u5bb9&#xff1a;<\/p>\n<p>-m http.<\/p>\n<p>\u5018\u82e5\u4f60\u6253\u7b97\u8ddf\u4f60\u7684\u540c\u4e8b\u53bb\u5206\u4eab\u67d0\u4e9b\u4e1c\u897f, \u53c8\u6216\u8005\u662f\u6d4b\u8bd5\u4e00\u4e9b\u7b80\u6613\u7684 HTML \u7f51\u7ad9, \u90a3\u4e48\u8fd9\u6761\u547d\u4ee4\u662f\u9887\u4e3a\u6709\u7528\u7684\u3002<\/p>\n<p>23. \u591a\u884c\u5b57\u7b26\u4e32<\/p>\n<p>\u5373\u4fbf\u4f60\u80fd\u591f\u4e8e\u4ee3\u7801\u91cc\u501f\u7531\u4e09\u91cd\u5f15\u53f7&#xff08;\u201c \u201c \u201c \u201d \u201d \u201d&#xff09;\u53bb\u50a8\u5b58\u591a\u884c\u5b57\u7b26\u4e32, \u7136\u800c\u8fd9\u5e76\u975e\u662f\u7406\u60f3\u7684\u65b9\u5f0f\u3002\u4f60\u5728\u4e09\u91cd\u5f15\u53f7\u4e2d\u95f4\u7684\u5168\u90e8\u5185\u5bb9\u90fd\u4f1a\u53d8\u4e3a\u5b57\u7b26\u4e32, \u6b63\u5982\u4e0b\u9762\u8fd9\u5e45\u56fe\u6240\u5c55\u793a\u7684\u90a3\u822c, \u5c31\u8fde\u683c\u5f0f\u7b26\u4e5f\u90fd\u53d8\u6210\u4e86\u5b57\u7b26\u4e32\u3002<\/p>\n<p>\u8f83\u4e3a\u4e8e\u6211\u800c\u8a00, \u66f4\u503e\u5411\u8fd0\u7528\u7b2c\u4e8c\u79cd\u65b9\u5f0f, \u6b64\u65b9\u5f0f\u80fd\u591f\u5c06\u4f17\u591a\u884c\u5f52\u96c6\u4e8e\u4e00\u5904, \u4e0e\u6b64\u540c\u65f6, \u4f60\u7684\u4ee3\u7801\u683c\u5f0f\u4ea6\u4f1a\u9887\u4e3a\u826f\u597d, \u800c\u8be5\u65b9\u6cd5\u4ec5\u6709\u7684\u7f3a\u70b9\u4fbf\u662f, \u4f60\u9700\u6e05\u6670\u5730\u5224\u5b9a\u6362\u884c\u7684\u4f4d\u7f6e\u3002<\/p>\n<p><img decoding=\"async\" alt=\"Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570\" src=\"2026-08-01bqzjqh5vjhg.png\" \/><\/p>\n<p>24. \u6761\u4ef6\u8d4b\u503c\u7684\u4e09\u5143\u8fd0\u7b97\u7b26<\/p>\n<p>\u8fd9\u662f\u90a3\u4e9b\u8ba9\u4f60\u4ee3\u7801\u5728\u4fdd\u8bc1\u53ef\u8bfb\u6027\u7684\u60c5\u51b5\u4e0b\u66f4\u7b80\u6d01\u7684\u65b9\u6cd5\u4e4b\u4e00&#xff1a;<\/p>\n<p>if<\/p>\n<p>else<\/p>\n<p>\u5b9e\u4f8b\u5982\u4e0b&#xff1a;<\/p>\n<p>x &#061; &#034;!&#034; if (y &#061;&#061; 2) else &#034;!&#034;<\/p>\n<p>25. \u7edf\u8ba1\u51fa\u73b0\u6570<\/p>\n<p>\u5bf9\u4e8elist\u5f53\u4e2d\u7684\u5404\u4e2a\u503c, \u4f60\u80fd\u591f\u8fd0\u7528\u5e93\u53bb\u83b7\u53d6\u5176\u8ba1\u6570, \u7136\u540e\u5c06\u8fd9\u4e9b\u8ba1\u6570\u8fd4\u56de\u800c\u5f62\u6210\u4e00\u4e2a:<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_Python\u6280\u5de7_IPython\u9b54\u6cd5\u51fd\u6570\" src=\"2026-08-01voh5m5av53o.png\" \/><\/p>\n<p>26. \u6bd4\u8f83\u7b26\u94fe&#xff08; of &#xff09;<\/p>\n<p>\u90a3\u91cc, \u4f60\u80fd\u591f\u5c06\u6bd4\u8f83\u7b26\u8854\u63a5\u6210\u4e00\u6761\u94fe, \u5982\u6b64\u4ee3\u7801\u4f1a\u66f4\u5177\u53ef\u8bfb\u6027, \u5e76\u4e14\u66f4\u4e3a\u7b80\u6d01\u3002<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7_Python\u63a7\u5236\u53cd\u8f6c\" src=\"2026-08-01ua3eheqw2i4.png\" \/><\/p>\n<p>27. \u52a0\u4e00\u4e9b\u8272\u5f69<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c_Python\u6280\u5de7\" src=\"2026-08-01i4smui53xck.png\" \/><\/p>\n<p>\u4e2d \u7684\u622a\u5c4f<\/p>\n<p>\u4f7f\u7528 &#xff0c;\u4f60\u53ef\u4ee5\u5728\u4f60\u7684\u7ec8\u7aef\u4e0a\u6dfb\u52a0\u70b9\u989c\u8272\u3002<\/p>\n<p><img decoding=\"async\" alt=\"Python\u6280\u5de7_IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c\" src=\"2026-08-014m11xp0ymhf.png\" \/><\/p>\n<p>28. \u65e5\u671f\u8ba1\u7b97<\/p>\n<p>\u8fd9\u4e2a\u6a21\u5757\u5e76\u975e\u666e\u901a\u6a21\u5757, \u5b83\u5bf9\u6807\u51c6\u7684\u540c\u6837\u88ab\u79f0\u4f5c\u6a21\u5757\u4e4b\u7269\u8fdb\u884c\u4e86\u6781\u5927\u7a0b\u5ea6\u7684\u6269\u5145\u3002\u8bf7\u5148\u53bb\u628a\u8fd9\u4e2a\u6a21\u5757\u4e0b\u8f7d\u4e0b\u6765:<\/p>\n<p>pip3 &#8211;<\/p>\n<p>\u4f60\u80fd\u591f\u8fd0\u7528\u8fd9\u4e2a\u5e93\u53bb\u5f00\u5c55\u8bf8\u591a\u76f8\u5f53\u9177\u7684\u4e8b\u513f\u3002\u6211\u4ec5\u4ec5\u4f1a\u4e3a\u4f60\u4eec\u8bb2\u8ff0\u6211\u6240\u53d1\u89c9\u7684\u6781\u4e3a\u6709\u7528\u7684\u4e00\u4e2a\u5b9e\u4f8b: \u50cf\u662f\u65e5\u5fd7\u6587\u4ef6\u4e4b\u4e2d\u65e5\u671f\u7684\u90a3\u79cd\u6a21\u7cca\u89e3\u6790\u4e4b\u7c7b\u7684\u3002<\/p>\n<p><img decoding=\"async\" alt=\"Python\u63a7\u5236\u53cd\u8f6c_IPython\u9b54\u6cd5\u51fd\u6570_Python\u6280\u5de7\" src=\"2026-08-01uq4ztfnqpnr.png\" \/><\/p>\n<p>\u9700\u8bb0\u4f4f\u8fd9\u6837\u4e00\u70b9, \u5f53\u57fa\u672c\u7684\u65e5\u671f\u51fd\u6570\u9762\u5bf9\u4e00\u4e9b\u95ee\u9898\u800c\u663e\u5f97\u6beb\u65e0\u529e\u6cd5\u7684\u65f6\u5019&#xff0c;\u6b64\u65f6, \u5c31\u80fd\u53d1\u6325\u4f5c\u7528\u3002<\/p>\n<p>29. \u6574\u9664<\/p>\n<p><img decoding=\"async\" alt=\"IPython\u9b54\u6cd5\u51fd\u6570_Python\u63a7\u5236\u53cd\u8f6c_Python\u6280\u5de7\" src=\"2026-08-01fm3cixchwlv.png\" \/><\/p>\n<p>\u56fe\u6e90&#xff1a;\u516c\u5171\u6e90 &#8211;<\/p>\n<p>2\u5f53\u4e2d\u7684\u9664\u53f7&#xff08;\/&#xff09;, \u5b83\u9ed8\u8ba4\u662f\u6574\u9664, \u8fd9\u79cd\u60c5\u51b5\u662f\u6709\u6761\u4ef6\u7684, \u6761\u4ef6\u662f\u9664\u975e\u5176\u4e2d\u4e00\u4e2a\u88ab\u7528\u6765\u64cd\u4f5c\u7684\u6570\u662f\u6d6e\u70b9\u6570, \u6240\u4ee5\u6700\u7ec8\u4f60\u4f1a\u5f97\u5230\u5448\u73b0\u51fa\u6765\u662f\u8fd9\u6837\u7684\u4e00\u79cd\u7ed3\u679c:<\/p>\n<p># 2<\/p>\n<p>5 \/ 2 &#061; 2<\/p>\n<p>5 \/ 2.0 &#061; 2.5<\/p>\n<p>\u5728\u6570\u5b573\u91cc\u9762, \u9664\u53f7\u6240\u5f97\u5230\u7684\u7ed3\u679c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u662f\u6d6e\u70b9\u6570, \u7136\u800c\u53cc\u659c\u6760\u5374\u6210\u4e3a\u4e86\u8fdb\u884c\u6574\u9664\u8fd0\u7b97\u7684\u7b26\u53f7, \u6240\u4ee5\u5728\u8fd9\u4e2a\u65f6\u5019\u6700\u7ec8\u7684\u7ed3\u679c\u5c31\u53d8\u4e3a\u4e86:<\/p>\n<p>3<\/p>\n<p>5 \/ 2 &#061; 2.5<\/p>\n<p>5 \/\/ 2 &#061; 2<\/p>\n<p>\u5982\u679c\u60f3\u8981\u6df1\u5165\u4e86\u89e3\u8fd9\u4e00\u6539\u53d8&#xff0c;\u8bf7\u53c2\u8003&#xff1a;\u3002<\/p>\n<p>30. \u4f7f\u7528 \u68c0\u6d4b<\/p>\n<p>\u4f60\u80fd\u591f\u8fd0\u7528\u6a21\u5757\u53bb\u68c0\u9a8c\u4e00\u4e2a\u6587\u4ef6\u7684\u60c5\u51b5, \u5f53\u4f60\u5904\u4e8e\u5256\u6790\u8bf8\u591a\u6587\u672c\u4e4b\u9645, \u8be5\u6a21\u5757\u4fbf\u4f1a\u663e\u5f97\u9887\u5177\u529f\u7528, \u4f60\u80fd\u7528\u5982\u4e0b\u8fd9\u6761\u6307\u4ee4\u5c06\u5b83\u4e0b\u8f7d\u4e0b\u6765:<\/p>\n<p>pip<\/p>\n<p>\u4f60\u73b0\u5728\u4f1a\u6709\u4e00\u4e2a\u547d\u4ee4\u884c\u5de5\u5177\u2014\u2014&#xff0c;\u8fd9\u4e2a\u5de5\u5177\u7684\u4f7f\u7528\u65b9\u5f0f\u662f&#xff1a;<\/p>\n<p>.txt<\/p>\n<p>.txt: ascii with 1.0<\/p>\n<p>\u4f60\u53ef\u4ee5\u4ee5\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u8fd9\u4e2a\u5e93&#xff0c;\u8be6\u89c1&#xff1a;<\/p>\n<p>\u8fd9\u5c31\u662f\u6240\u6709\u7684\u6559\u7a0b\u5566&#xff01;\u5e0c\u671b\u5927\u5bb6\u559c\u6b22\u8fd9\u4e9b\u6280\u5de7&#xff01;<\/p>\n<p>\u53c2\u8003\u94fe\u63a5&#xff1a;<\/p>\n<p>\u672c\u6587\u4e3a\u673a\u5668\u4e4b\u5fc3\u7f16\u8bd1&#xff0c;\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u672c\u516c\u4f17\u53f7\u83b7\u5f97\u6388\u6743\u3002<\/p>\n<p>\u4f3c\u4e4e\u4f60\u6ca1\u6709\u63d0\u4f9b\u5177\u4f53\u53e5\u5b50\u5185\u5bb9, \u8bf7\u4f60\u63d0\u4f9b\u76f8\u5173\u53e5\u5b50, \u4ee5\u4fbf\u6211\u6309\u7167\u8981\u6c42\u8fdb\u884c\u6539\u5199\u3002<\/p>\n<p>\u52a0\u5165\u673a\u5668\u4e4b\u5fc3&#xff08;\u5168\u804c\u8bb0\u8005 \/ \u5b9e\u4e60\u751f&#xff09;&#xff1a;<\/p>\n<p>\u6295\u7a3f\u6216\u5bfb\u6c42\u62a5\u9053&#xff1a;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3002\u5b58\u5728\u7740\u4e00\u9879\u5177\u5907\u6548\u7528\u7684\u529f\u80fd, \u6b64\u529f\u80fd\u4e43\u662f\u53bb\u8c03\u53d6\u5148\u524d\u7684\u547d\u4ee4\u8f93\u51fa, \u5728\u8fd9\u91cc, \u8f93\u5165\u4ee5\u53ca\u8f93\u51fa\u4e8b\u5b9e\u4e0a\u5747\u4e3a\u5bf9\u8c61, \u4e3e\u4f8b\u800c\u8a00, \u4f60\u80fd\u591f\u8fd0\u7528Out\u53bb\u8c03\u53d6\u7b2c\u4e09\u6761\u547d\u4ee4\u7684\u8f93\u51fa\u3002\u4f60\u53ef\u4ee5\u7528\u4e0b\u9762\u8fd9\u6761\u547d\u4ee4\u5b89\u88c5 &#xff1a;pip34. \u5217\u8868\u8868\u8fbe\u5f0f\u4e00\u65e6\u62e5\u6709\u5217\u8868\u8868\u8fbe\u5f0f, \u4f60\u4fbf\u65e0\u9700\u518d\u501f\u52a9for loop\u53bb\u751f\u6210\u4e00\u4e2alist\u4e86, \u5176\u57fa\u672c\u8bed\u6cd5\u662f\u5982\u6b64\u8fd9\u822c:for item in list if\u8fd9\u5c31\u662f\u4e00\u4e2a\u751f\u6210\u5305\u542b\u4e00\u4e32\u6570\u5b57\u7684 list \u7684\u7b80\u5355\u4f8b\u5b50\u3002\u4e8e\u8fd9\u6761\u547d\u4ee4\u5f53\u4e2d, \u662f\u80fd\u591f\u8fd0\u7528\u8868\u8fbe\u5f0f&#xff08;&#xff09;\u7684,<\/p>\n","protected":false},"author":2,"featured_media":88860,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10063,6333,10062,4105,683],"topic":[],"class_list":["post-88880","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-emoji","tag-python3","tag-10062","tag-4105","tag-683"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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:\/\/www.wsisp.com\/helps\/88880.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u3002\u5b58\u5728\u7740\u4e00\u9879\u5177\u5907\u6548\u7528\u7684\u529f\u80fd, \u6b64\u529f\u80fd\u4e43\u662f\u53bb\u8c03\u53d6\u5148\u524d\u7684\u547d\u4ee4\u8f93\u51fa, \u5728\u8fd9\u91cc, \u8f93\u5165\u4ee5\u53ca\u8f93\u51fa\u4e8b\u5b9e\u4e0a\u5747\u4e3a\u5bf9\u8c61, \u4e3e\u4f8b\u800c\u8a00, \u4f60\u80fd\u591f\u8fd0\u7528Out\u53bb\u8c03\u53d6\u7b2c\u4e09\u6761\u547d\u4ee4\u7684\u8f93\u51fa\u3002\u4f60\u53ef\u4ee5\u7528\u4e0b\u9762\u8fd9\u6761\u547d\u4ee4\u5b89\u88c5 &#xff1a;pip34. \u5217\u8868\u8868\u8fbe\u5f0f\u4e00\u65e6\u62e5\u6709\u5217\u8868\u8868\u8fbe\u5f0f, \u4f60\u4fbf\u65e0\u9700\u518d\u501f\u52a9for loop\u53bb\u751f\u6210\u4e00\u4e2alist\u4e86, \u5176\u57fa\u672c\u8bed\u6cd5\u662f\u5982\u6b64\u8fd9\u822c:for item in list if\u8fd9\u5c31\u662f\u4e00\u4e2a\u751f\u6210\u5305\u542b\u4e00\u4e32\u6570\u5b57\u7684 list \u7684\u7b80\u5355\u4f8b\u5b50\u3002\u4e8e\u8fd9\u6761\u547d\u4ee4\u5f53\u4e2d, \u662f\u80fd\u591f\u8fd0\u7528\u8868\u8fbe\u5f0f&#xff08;&#xff09;\u7684,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/88880.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-01T13:25:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132504-6a6df3b0cd7fa.jpg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/88880.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/88880.html\",\"name\":\"Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-01T13:25:08+00:00\",\"dateModified\":\"2026-08-01T13:25:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/88880.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/88880.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/88880.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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:\/\/www.wsisp.com\/helps\/88880.html","og_locale":"zh_CN","og_type":"article","og_title":"Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u3002\u5b58\u5728\u7740\u4e00\u9879\u5177\u5907\u6548\u7528\u7684\u529f\u80fd, \u6b64\u529f\u80fd\u4e43\u662f\u53bb\u8c03\u53d6\u5148\u524d\u7684\u547d\u4ee4\u8f93\u51fa, \u5728\u8fd9\u91cc, \u8f93\u5165\u4ee5\u53ca\u8f93\u51fa\u4e8b\u5b9e\u4e0a\u5747\u4e3a\u5bf9\u8c61, \u4e3e\u4f8b\u800c\u8a00, \u4f60\u80fd\u591f\u8fd0\u7528Out\u53bb\u8c03\u53d6\u7b2c\u4e09\u6761\u547d\u4ee4\u7684\u8f93\u51fa\u3002\u4f60\u53ef\u4ee5\u7528\u4e0b\u9762\u8fd9\u6761\u547d\u4ee4\u5b89\u88c5 &#xff1a;pip34. \u5217\u8868\u8868\u8fbe\u5f0f\u4e00\u65e6\u62e5\u6709\u5217\u8868\u8868\u8fbe\u5f0f, \u4f60\u4fbf\u65e0\u9700\u518d\u501f\u52a9for loop\u53bb\u751f\u6210\u4e00\u4e2alist\u4e86, \u5176\u57fa\u672c\u8bed\u6cd5\u662f\u5982\u6b64\u8fd9\u822c:for item in list if\u8fd9\u5c31\u662f\u4e00\u4e2a\u751f\u6210\u5305\u542b\u4e00\u4e32\u6570\u5b57\u7684 list \u7684\u7b80\u5355\u4f8b\u5b50\u3002\u4e8e\u8fd9\u6761\u547d\u4ee4\u5f53\u4e2d, \u662f\u80fd\u591f\u8fd0\u7528\u8868\u8fbe\u5f0f&#xff08;&#xff09;\u7684,","og_url":"https:\/\/www.wsisp.com\/helps\/88880.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-01T13:25:08+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260801132504-6a6df3b0cd7fa.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/88880.html","url":"https:\/\/www.wsisp.com\/helps\/88880.html","name":"Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-01T13:25:08+00:00","dateModified":"2026-08-01T13:25:08+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/88880.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/88880.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/88880.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Python2 \u5df2\u7ec8\u7ed3\uff0c\u5165\u624bPython 3\uff0c\u4f60\u9700\u8981\u8fd930\u4e2a\u6280\u5de7"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/88880","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=88880"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/88880\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/88860"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=88880"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=88880"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=88880"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=88880"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}