{"id":63736,"date":"2026-01-22T10:16:25","date_gmt":"2026-01-22T02:16:25","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/63736.html"},"modified":"2026-01-22T10:16:25","modified_gmt":"2026-01-22T02:16:25","slug":"%e8%93%9d%e6%a1%a5%e6%9d%afpython%e5%a4%87%e8%b5%9b%e7%ac%94%e8%ae%b0%e4%b9%8b%ef%bc%88%e4%b8%80%ef%bc%89python%e8%af%ad%e6%b3%95%e5%9f%ba%e7%a1%80%e5%8f%8a%e7%ae%97%e6%b3%95%e5%85%a5%e9%97%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/63736.html","title":{"rendered":"\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8"},"content":{"rendered":"<h3>\u524d\u8a00<\/h3>\n<p>\u535a\u4e3b\u5728\u5199\u7b14\u8bb0\u65f6\u51c6\u5907\u7684\u662f\u672c\u79d1\u751fB\u7ec4\u8d5b\u9053&#xff0c;\u5185\u5bb9\u53ef\u4f9b\u51c6\u5907\u540c\u6837\u8d5b\u9053\u53ca\u4ee5\u4e0b\u7684\u540c\u5b66\u53c2\u8003\u3002<\/p>\n<p>\u5e0c\u671b\u5404\u4f4d\u540c\u5b66\u8499\u7684\u5168\u5bf9&#xff0c;\u8003\u7684\u5168\u4f1a\u3002<\/p>\n<p>\u5982\u679c\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u53ef\u4ee5\u70b9\u8d5e\u8bc4\u8bba\u9f13\u52b1\u4e00\u4e0b\u535a\u4e3b\u5417&#xff1f;\u62dc\u6258\u62dc\u6258\u2014\u2014<\/p>\n<p>\u8a00\u5f52\u6b63\u4f20&#xff0c;\u6574\u7bc7\u7b14\u8bb0\u5171\u5206\u4e3a\u5341\u7ae0&#xff0c;\u90fd\u662f\u535a\u4e3b\u5728\u51c6\u590725\u5e74\u84dd\u6865\u676f\u65f6\u6240\u5199&#xff0c;\u542c\u7684\u7f51\u8bfe\u662f\u8fd9\u4e2a&#xff0c;\u8bb2\u7684\u975e\u5e38\u597d&#xff0c;\u5f88\u9002\u5408\u96f6\u57fa\u7840\u901f\u6210&#xff0c;\u5982\u679c\u6709\u542c\u4e0d\u61c2\u7684\u53ef\u4ee5\u591a\u542c\u51e0\u904d<\/p>\n<p>https:\/\/www.bilibili.com\/video\/BV1Zs9VYrEgg?spm_id_from&#061;333.788.videopod.sections&#038;vd_source&#061;5edde23df276e6fb4a94821fa44f38b5<\/p>\n<p>\u76ee\u5f55\u5982\u4e0b&#xff1a;<\/p>\n<p>1.Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8 2.\u8bed\u6cd5\u8fdb\u9636&amp;\u5e38\u7528\u6570\u636e\u7ed3\u6784&amp;\u7b97\u6cd5\u5165\u95e8 3.\u8d2a\u5fc3&amp;\u6392\u5e8f 4.\u54c8\u5e0c&amp;\u66b4\u529b&amp;\u524d\u7f00 5.\u4e8c\u5206\u67e5\u627e&amp;\u4e8c\u5206\u7b54\u6848 6.\u641c\u7d22&amp;BFS&amp;DFS 7.[\u6570\u636e\u7ed3\u6784]\u5e76\u67e5\u96c6&amp;\u5806 8.\u52a8\u6001\u89c4\u5212 9.\u56fe\u8bba 10.\u6570\u8bba\u57fa\u7840&amp;\u65e5\u671f\u95ee\u9898<\/p>\n<h3>\u4e00\u3001\u8bed\u6cd5\u57fa\u7840<\/h3>\n<h4>&#xff08;\u4e00&#xff09;\u6807\u8bc6\u7b26<\/h4>\n<li>\u7b2c\u4e00\u4e2a\u5b57\u7b26\u5fc5\u987b\u662f\u5b57\u6bcd\u6216\u4e0b\u5212\u7ebf&#xff08;_&#xff09;<\/li>\n<li>\u5bf9\u5927\u5c0f\u5199\u654f\u611f<\/li>\n<li>\u652f\u6301\u4e2d\u6587\u4f5c\u4e3a\u53d8\u91cf\u540d<\/li>\n<h4>&#xff08;\u4e8c&#xff09;\u4fdd\u7559\u5b57<\/h4>\n<li>\u5b9a\u4e49&#xff1a;Python \u5185\u7f6e\u7684\u5177\u6709\u7279\u5b9a\u529f\u80fd\u7684\u5355\u8bcd<\/li>\n<li>\u9650\u5236&#xff1a;\u4e0d\u80fd\u7528\u4f5c\u4efb\u4f55\u6807\u8bc6\u7b26\u540d\u79f0<\/li>\n<h4>&#xff08;\u4e09&#xff09;\u5b57\u7b26\u4e32<\/h4>\n<li>\u5f15\u53f7\u4f7f\u7528&#xff1a;\u5355\u5f15\u53f7&#xff08;&#039;&#xff09;\u548c\u53cc\u5f15\u53f7&#xff08;&#034;&#xff09;\u529f\u80fd\u5b8c\u5168\u76f8\u540c<\/li>\n<li>\u591a\u884c\u5b57\u7b26\u4e32&#xff1a;\u53ef\u901a\u8fc7\u4e09\u5f15\u53f7&#xff08;&#039;&#039;&#039; \u6216 &#034;&#034;&#034;&#xff09;\u5b9a\u4e49<\/li>\n<li>\u8f6c\u4e49\u7b26&#xff1a;\u4f7f\u7528\u53cd\u659c\u6760&#xff08;\\\\&#xff09;\u5b9e\u73b0\u8f6c\u4e49&#xff0c;\u5982 \\\\n&#xff08;\u6362\u884c&#xff09;\u3001\\\\t&#xff08;\u5236\u8868\u7b26&#xff09;<\/li>\n<li>\u539f\u59cb\u5b57\u7b26\u4e32&#xff1a;\u5728\u5b57\u7b26\u4e32\u524d\u52a0 r&#xff0c;\u4f7f\u53cd\u659c\u6760\u4e0d\u53d1\u751f\u8f6c\u4e49&#xff0c;\u4f8b&#xff1a;r&#034;this is a line with \\\\n&#034; \u4f1a\u539f\u6837\u663e\u793a \\\\n<\/li>\n<li>\u5b57\u7b26\u4e32\u8fd0\u7b97&#xff1a;\n<ul>\n<li>\u8fde\u63a5&#xff1a;\u4f7f\u7528 &#043; \u8fd0\u7b97\u7b26&#xff0c;\u4f8b&#xff1a;&#034;abc&#034;&#043;&#034;def&#034;&#061;&#034;abcdef&#034;<\/li>\n<li>\u91cd\u590d&#xff1a;\u4f7f\u7528 * \u8fd0\u7b97\u7b26&#xff0c;\u4f8b&#xff1a;&#034;ab&#034;*2&#061;&#034;abab&#034;<\/li>\n<\/ul>\n<\/li>\n<li>\u7d22\u5f15\u65b9\u5f0f&#xff1a;\n<ul>\n<li>\u6b63\u5411\u7d22\u5f15&#xff1a;\u4ece\u5de6\u5f80\u53f3&#xff0c;\u8d77\u59cb\u503c\u4e3a 0<\/li>\n<li>\u53cd\u5411\u7d22\u5f15&#xff1a;\u4ece\u53f3\u5f80\u5de6&#xff0c;\u8d77\u59cb\u503c\u4e3a &#8211; 1<\/li>\n<\/ul>\n<\/li>\n<li>\u7279\u6027&#xff1a;\u5b57\u7b26\u4e32\u4e3a\u4e0d\u53ef\u53d8\u5e8f\u5217&#xff0c;\u65e0\u6cd5\u76f4\u63a5\u4fee\u6539\u5355\u4e2a\u5b57\u7b26<\/li>\n<li>\u5207\u7247\u89c4\u5219&#xff1a;str [start:end:step]&#xff0c;\u9075\u5faa\u5de6\u95ed\u53f3\u5f00\u539f\u5219&#xff08;start \u5305\u542b&#xff0c;end \u4e0d\u5305\u542b&#xff09;&#xff0c;step \u4e3a\u6b65\u957f&#xff08;\u9ed8\u8ba4 1&#xff09;\n<ul>\n<li>\u4f8b&#xff1a;\u8bbe s&#061;&#039;123456789&#039;\n<ul>\n<li>print (s) \u2192 \u8f93\u51fa&#xff1a;123456789<\/li>\n<li>print (s [0:-1]) \u2192 \u8f93\u51fa&#xff1a;12345678&#xff08;\u7b2c\u4e00\u4e2a\u5230\u5012\u6570\u7b2c\u4e8c\u4e2a\u5b57\u7b26&#xff09;<\/li>\n<li>print (s [0]) \u2192 \u8f93\u51fa&#xff1a;1&#xff08;\u7b2c\u4e00\u4e2a\u5b57\u7b26&#xff09;<\/li>\n<li>print (s [2:5]) \u2192 \u8f93\u51fa&#xff1a;345&#xff08;\u7b2c\u4e09\u4e2a\u5230\u7b2c\u516d\u4e2a\u5b57\u7b26&#xff0c;\u4e0d\u5305\u542b\u7b2c\u516d\u4e2a&#xff09;<\/li>\n<li>print (s [2:]) \u2192 \u8f93\u51fa&#xff1a;3456789&#xff08;\u7b2c\u4e09\u4e2a\u5f00\u59cb\u540e\u7684\u6240\u6709\u5b57\u7b26&#xff09;<\/li>\n<li>print (s [1:5:2]) \u2192 \u8f93\u51fa&#xff1a;24&#xff08;\u7b2c\u4e8c\u4e2a\u5230\u7b2c\u4e94\u4e2a\u5b57\u7b26&#xff0c;\u6b65\u957f\u4e3a 2&#xff09;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<h4>&#xff08;\u56db&#xff09;\u6a21\u5757\u5bfc\u5165<\/h4>\n<li>\u5bfc\u5165\u6574\u4e2a\u6a21\u5757&#xff1a;import \u6a21\u5757\u540d&#xff0c;\u4f8b&#xff1a;import math<\/li>\n<li>\u6a21\u5757\u8bbe\u7f6e\u522b\u540d&#xff1a;import \u6a21\u5757\u540d as \u522b\u540d&#xff0c;\u4f8b&#xff1a;import numpy as np<\/li>\n<li>\u5bfc\u5165\u6a21\u5757\u4e2d\u7279\u5b9a\u51fd\u6570&#xff1a;from \u6a21\u5757\u540d import \u51fd\u6570\u540d&#xff0c;\u4f8b&#xff1a;from math import sqrt<\/li>\n<li>\u5bfc\u5165\u6a21\u5757\u4e2d\u591a\u4e2a\u51fd\u6570&#xff1a;from \u6a21\u5757\u540d import \u51fd\u6570 1, \u51fd\u6570 2,&#8230;&#xff0c;\u4f8b&#xff1a;from math import sqrt,sin,cos<\/li>\n<h4>&#xff08;\u4e94&#xff09;print \u51fd\u6570<\/h4>\n<li>\u81ea\u5b9a\u4e49\u5206\u9694\u7b26&#xff1a;\u901a\u8fc7 sep \u53c2\u6570\u8bbe\u7f6e&#xff0c;\u4f8b&#xff1a;print (2023,13,4,sep&#061;&#039;-&#039;) \u2192 \u8f93\u51fa&#xff1a;2023-13-4<\/li>\n<li>\u81ea\u5b9a\u4e49\u7ed3\u675f\u7b26&#xff1a;\u901a\u8fc7 end \u53c2\u6570\u8bbe\u7f6e&#xff0c;\u4f8b&#xff1a;print (&#034;Hello&#034;,end&#061;&#039; &#039;) \u2192 \u8f93\u51fa\u540e\u4e0d\u6362\u884c&#xff0c;\u63a5\u4e00\u4e2a\u7a7a\u683c<\/li>\n<li>\u683c\u5f0f\u5316\u8f93\u51fa&#xff1a;\n<ul>\n<li>f-string \u683c\u5f0f&#xff1a;print (f&#034;{\u53d8\u91cf\u540d}&#034;)&#xff0c;\u4f8b&#xff1a;name&#061;&#034;Alice&#034;;print (f&#034;Hello,{name}&#034;) \u2192 \u8f93\u51fa&#xff1a;Hello,Alice<\/li>\n<\/ul>\n<\/li>\n<li>\u9ad8\u6548\u8f93\u51fa&#xff1a;\n<ul>\n<li>\u4f7f\u7528 print (*list) \u5feb\u901f\u8f93\u51fa\u5217\u8868\u5185\u5bb9<\/li>\n<li>\u7ed3\u5408 sep \u548c end \u53c2\u6570\u63a7\u5236\u8f93\u51fa\u683c\u5f0f<\/li>\n<\/ul>\n<\/li>\n<h4>&#xff08;\u516d&#xff09;\u6570\u636e\u7c7b\u578b<\/h4>\n<li>\u5e38\u7528\u6570\u636e\u7c7b\u578b\u53ca\u7279\u6027<br \/>\n<table>\n<tr>\u6570\u636e\u7c7b\u578b\u82f1\u6587\u6807\u8bc6\u7279\u6027\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>\u6574\u6570<\/td>\n<td>int<\/td>\n<td>\u652f\u6301\u5927\u6574\u6570\u8fd0\u7b97<\/td>\n<td>a&#061;10**100<\/td>\n<\/tr>\n<tr>\n<td>\u6d6e\u70b9\u6570<\/td>\n<td>float<\/td>\n<td>\u5b58\u5728\u7cbe\u5ea6\u95ee\u9898<\/td>\n<td>b&#061;3.14<\/td>\n<\/tr>\n<tr>\n<td>\u5b57\u7b26\u4e32<\/td>\n<td>str<\/td>\n<td>\u4e0d\u53ef\u53d8\u5e8f\u5217&#xff0c;\u652f\u6301\u5207\u7247\u548c\u683c\u5f0f\u5316<\/td>\n<td>s&#061;&#034;Hello&#034;<\/td>\n<\/tr>\n<tr>\n<td>\u5217\u8868<\/td>\n<td>list<\/td>\n<td>\u53ef\u53d8\u5e8f\u5217&#xff0c;\u652f\u6301\u589e\u5220\u6539\u67e5<\/td>\n<td>lst&#061;[1,2,3]<\/td>\n<\/tr>\n<tr>\n<td>\u5143\u7ec4<\/td>\n<td>tuple<\/td>\n<td>\u4e0d\u53ef\u53d8\u5e8f\u5217<\/td>\n<td>tup&#061;(1,2,3)<\/td>\n<\/tr>\n<tr>\n<td>\u96c6\u5408<\/td>\n<td>set<\/td>\n<td>\u65e0\u5e8f\u4e0d\u91cd\u590d&#xff0c;\u652f\u6301\u96c6\u5408\u8fd0\u7b97<\/td>\n<td>s&#061;{1,2,3}<\/td>\n<\/tr>\n<tr>\n<td>\u5b57\u5178<\/td>\n<td>dict<\/td>\n<td>\u952e\u503c\u5bf9\u6620\u5c04&#xff0c;\u952e\u552f\u4e00\u4e14\u4e0d\u53ef\u53d8<\/td>\n<td>d&#061;{&#034;key&#034;:&#034;value&#034;}<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li>\u53ef\u53d8\u6027\u5206\u7c7b\n<ul>\n<li>\u4e0d\u53ef\u53d8\u7c7b\u578b&#xff1a;\u6574\u6570\u3001\u5b57\u7b26\u4e32\u3001\u5143\u7ec4<\/li>\n<li>\u53ef\u53d8\u7c7b\u578b&#xff1a;\u5217\u8868\u3001\u5b57\u5178\u3001\u96c6\u5408<\/li>\n<\/ul>\n<\/li>\n<h4>&#xff08;\u4e03&#xff09;\u51fd\u6570<\/h4>\n<li>\u57fa\u672c\u5b9a\u4e49&#xff1a;def \u51fd\u6570\u540d (\u53c2\u6570\u5217\u8868)&#xff1a;\n<ul>\n<li>\u51fd\u6570\u4f53<\/li>\n<li>\u8fd4\u56de\u503c&#xff1a;\u901a\u8fc7 return \u8bed\u53e5\u8fd4\u56de&#xff0c;\u4f8b&#xff1a; def add(a,b):<br \/>\n    return a&#043;b<br \/>\nprint(add(1,2))  # \u8f93\u51fa&#xff1a;3\n <\/li>\n<\/ul>\n<\/li>\n<li>\u9ed8\u8ba4\u53c2\u6570&#xff1a;\u5b9a\u4e49\u51fd\u6570\u65f6\u6307\u5b9a\u53c2\u6570\u9ed8\u8ba4\u503c&#xff0c;\u8c03\u7528\u65f6\u53ef\u7701\u7565\u8be5\u53c2\u6570&#xff0c;\u4f8b&#xff1a; def power(x,n&#061;2):<br \/>\n    return x**n<br \/>\nprint(power(3))  # \u8f93\u51fa&#xff1a;9\n <\/li>\n<li>\u53ef\u53d8\u53c2\u6570&#xff1a;\n<ul>\n<li>\u4f4d\u7f6e\u53ef\u53d8\u53c2\u6570&#xff08;*args&#xff09;&#xff1a;\u63a5\u6536\u4efb\u610f\u6570\u91cf\u4f4d\u7f6e\u53c2\u6570&#xff0c;\u6253\u5305\u4e3a\u5143\u7ec4&#xff0c;\u4f8b&#xff1a; def sum_all(*args):<br \/>\n    return sum(args)<br \/>\nprint(sum_all(1,2,3))  # \u8f93\u51fa&#xff1a;6\n <\/li>\n<li>\u5173\u952e\u5b57\u53ef\u53d8\u53c2\u6570&#xff08;**kwargs&#xff09;&#xff1a;\u63a5\u6536\u4efb\u610f\u6570\u91cf\u5173\u952e\u5b57\u53c2\u6570&#xff0c;\u6253\u5305\u4e3a\u5b57\u5178&#xff0c;\u4f8b&#xff1a; def print_info(**kwargs):<br \/>\n    for key,value in kwargs.items():<br \/>\n        print(f&#034;{key}:{value}&#034;)<br \/>\nprint_info(name&#061;&#034;Alice&#034;,age&#061;25)  # \u8f93\u51fa&#xff1a;name:Alice, age:25\n <\/li>\n<\/ul>\n<\/li>\n<li>Lambda \u51fd\u6570&#xff08;\u533f\u540d\u51fd\u6570&#xff09;&#xff1a;\n<ul>\n<li>\u8bed\u6cd5&#xff1a;lambda \u53c2\u6570\u5217\u8868&#xff1a;\u8868\u8fbe\u5f0f&#xff08;\u5192\u53f7\u524d\u4e3a\u8f93\u5165\u53c2\u6570&#xff0c;\u5192\u53f7\u540e\u4e3a\u8fd4\u56de\u8868\u8fbe\u5f0f&#xff09;<\/li>\n<li>\u7279\u6027&#xff1a;\u65e0\u51fd\u6570\u540d&#xff0c;\u4ec5\u542b\u4e00\u4e2a\u8868\u8fbe\u5f0f&#xff0c;\u8ba1\u7b97\u7ed3\u679c\u5373\u4e3a\u8fd4\u56de\u503c<\/li>\n<li>\u793a\u4f8b 1&#xff1a; x&#061;lambda a:a&#043;10<br \/>\nprint(x(5))  # \u8f93\u51fa&#xff1a;15\n <\/li>\n<li>\u793a\u4f8b 2&#xff08;\u83b7\u53d6\u4e2d\u4f4d\u6570&#xff09;&#xff1a; get_mid&#061;lambda nums: nums[len(nums)\/\/2]<br \/>\nprint(get_mid([1,4,5]))  # \u8f93\u51fa&#xff1a;4\n <\/li>\n<\/ul>\n<\/li>\n<h3>\u4e8c\u3001\u7b97\u6cd5\u5165\u95e8<\/h3>\n<h4>&#xff08;\u4e00&#xff09;\u5feb\u8bfb\u6a21\u677f<\/h4>\n<li>\u4f5c\u7528&#xff1a;\u63d0\u5347\u8f93\u5165\u8bfb\u53d6\u901f\u5ea6&#xff0c;\u9002\u7528\u4e8e\u5927\u91cf\u8f93\u5165\u573a\u666f<\/li>\n<li>\u5b9e\u73b0\u4ee3\u7801&#xff1a; import sys<br \/>\ninput&#061;lambda: sys.stdin.readline().strip()\n <\/li>\n<h4>&#xff08;\u4e8c&#xff09;\u5185\u7f6e\u6392\u5e8f\u7b97\u6cd5<\/h4>\n<li>sorted \u51fd\u6570&#xff1a;\n<ul>\n<li>\u8bed\u6cd5&#xff1a;sorted (\u53ef\u8fed\u4ee3\u5bf9\u8c61&#xff0c;key&#061;None, reverse&#061;False)<\/li>\n<li>\u7279\u6027&#xff1a;\u4e0d\u4fee\u6539\u539f\u53ef\u8fed\u4ee3\u5bf9\u8c61&#xff0c;\u8fd4\u56de\u6392\u5e8f\u540e\u7684\u65b0\u5217\u8868<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;\n<ul>\n<li>key&#xff1a;\u6392\u5e8f\u89c4\u5219&#xff08;\u53ef\u6307\u5b9a\u51fd\u6570&#xff09;<\/li>\n<li>reverse&#xff1a;\u6392\u5e8f\u65b9\u5411&#xff0c;False \u4e3a\u5347\u5e8f&#xff08;\u9ed8\u8ba4&#xff09;&#xff0c;True \u4e3a\u964d\u5e8f<\/li>\n<\/ul>\n<\/li>\n<li>\u793a\u4f8b 1&#xff08;\u9ed8\u8ba4\u5347\u5e8f&#xff09;&#xff1a; nums&#061;[5,3,8,6,7]<br \/>\nprint(sorted(nums))  # \u8f93\u51fa&#xff1a;[3,5,6,7,8]\n <\/li>\n<li>\u793a\u4f8b 2&#xff08;\u964d\u5e8f\u6392\u5e8f&#xff09;&#xff1a; print(sorted(nums, reverse&#061;True))  # \u8f93\u51fa&#xff1a;[8,7,6,5,3]\n <\/li>\n<li>\u793a\u4f8b 3&#xff08;\u6309\u5b57\u7b26\u4e32\u957f\u5ea6\u6392\u5e8f&#xff09;&#xff1a; words&#061;[&#034;apple&#034;,&#034;banana&#034;,&#034;kiwi&#034;,&#034;cherry&#034;]<br \/>\nprint(sorted(words, key&#061;len))  # \u8f93\u51fa&#xff1a;[&#034;kiwi&#034;,&#034;apple&#034;,&#034;cherry&#034;,&#034;banana&#034;]\n <\/li>\n<\/ul>\n<\/li>\n<li>list.sort \u65b9\u6cd5&#xff1a;\n<ul>\n<li>\u8bed\u6cd5&#xff1a;\u5217\u8868\u540d.sort (key&#061;None, reverse&#061;False)<\/li>\n<li>\u7279\u6027&#xff1a;\u76f4\u63a5\u4fee\u6539\u539f\u5217\u8868&#xff0c;\u65e0\u8fd4\u56de\u503c<\/li>\n<li>\u53c2\u6570\u8bf4\u660e&#xff1a;\u4e0e sorted \u51fd\u6570\u4e00\u81f4<\/li>\n<\/ul>\n<\/li>\n<h4>&#xff08;\u4e09&#xff09;\u8f93\u5165\u4e0e map \u6620\u5c04<\/h4>\n<li>map \u51fd\u6570\u8bed\u6cd5&#xff1a;map (\u51fd\u6570&#xff0c;\u53ef\u8fed\u4ee3\u5bf9\u8c61)&#xff0c;\u5c06\u51fd\u6570\u5e94\u7528\u4e8e\u53ef\u8fed\u4ee3\u5bf9\u8c61\u7684\u6bcf\u4e2a\u5143\u7d20&#xff0c;\u8fd4\u56de\u8fed\u4ee3\u5668<\/li>\n<li>\u5e38\u89c1\u8f93\u5165\u683c\u5f0f\u5904\u7406&#xff1a;\n<ul>\n<li>\u793a\u4f8b 1&#xff08;\u5355\u884c\u591a\u4e2a\u6574\u6570&#xff09;&#xff1a; a,b,c&#061;map(int,input().split())  # \u8f93\u5165&#xff1a;1 2 3<br \/>\nprint(a,b,c)  # \u8f93\u51fa&#xff1a;1 2 3\n <\/li>\n<li>\u793a\u4f8b 2&#xff08;\u591a\u884c\u591a\u4e2a\u6574\u6570&#xff09;&#xff1a; n&#061;int(input())  # \u8f93\u5165\u884c\u6570<br \/>\nlst&#061;[int(input()) for _ in range(n)]  # \u8bfb\u53d6n\u884c\u6574\u6570<br \/>\nprint(lst)\n <\/li>\n<li>\u793a\u4f8b 3&#xff08;\u77e9\u9635\u8f93\u5165&#xff09;&#xff1a; n,m&#061;map(int, input().split())  # \u8f93\u5165\u77e9\u9635\u884c\u6570n\u548c\u5217\u6570m<br \/>\nmatrix&#061;[list(map(int,input().split())) for _ in range(n)]  # \u8bfb\u53d6n\u884cm\u5217\u77e9\u9635<br \/>\nprint(matrix) <\/li>\n<\/ul>\n<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00<br \/>\n\u535a\u4e3b\u5728\u5199\u7b14\u8bb0\u65f6\u51c6\u5907\u7684\u662f\u672c\u79d1\u751fB\u7ec4\u8d5b\u9053&#xff0c;\u5185\u5bb9\u53ef\u4f9b\u51c6\u5907\u540c\u6837\u8d5b\u9053\u53ca\u4ee5\u4e0b\u7684\u540c\u5b66\u53c2\u8003\u3002<br \/>\n\u5e0c\u671b\u5404\u4f4d\u540c\u5b66\u8499\u7684\u5168\u5bf9&#xff0c;\u8003\u7684\u5168\u4f1a\u3002<br \/>\n\u5982\u679c\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u53ef\u4ee5\u70b9\u8d5e\u8bc4\u8bba\u9f13\u52b1\u4e00\u4e0b\u535a\u4e3b\u5417&#xff1f;\u62dc\u6258\u62dc\u6258\u2014\u2014<br \/>\n\u8a00\u5f52\u6b63\u4f20&#xff0c;\u6574\u7bc7\u7b14\u8bb0\u5171\u5206\u4e3a\u5341\u7ae0&#xff0c;\u90fd\u662f\u535a\u4e3b\u5728\u51c6\u590725\u5e74\u84dd\u6865\u676f\u65f6\u6240\u5199&#xff0c;\u542c\u7684\u7f51\u8bfe\u662f\u8fd9\u4e2a&#xff0c;\u8bb2\u7684\u975e\u5e38\u597d&#xff0c;\u5f88\u9002\u5408\u96f6\u57fa\u7840\u901f\u6210&#xff0c;\u5982\u679c\u6709\u542c\u4e0d\u61c2\u7684\u53ef\u4ee5\u591a\u542c\u51e0\u904d<br \/>\nhttps:\/\/<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,305,729],"topic":[],"class_list":["post-63736","post","type-post","status-publish","format-standard","hentry","category-server","tag-python","tag-305","tag-729"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8 - \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\/63736.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u524d\u8a00 \u535a\u4e3b\u5728\u5199\u7b14\u8bb0\u65f6\u51c6\u5907\u7684\u662f\u672c\u79d1\u751fB\u7ec4\u8d5b\u9053&#xff0c;\u5185\u5bb9\u53ef\u4f9b\u51c6\u5907\u540c\u6837\u8d5b\u9053\u53ca\u4ee5\u4e0b\u7684\u540c\u5b66\u53c2\u8003\u3002 \u5e0c\u671b\u5404\u4f4d\u540c\u5b66\u8499\u7684\u5168\u5bf9&#xff0c;\u8003\u7684\u5168\u4f1a\u3002 \u5982\u679c\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u53ef\u4ee5\u70b9\u8d5e\u8bc4\u8bba\u9f13\u52b1\u4e00\u4e0b\u535a\u4e3b\u5417&#xff1f;\u62dc\u6258\u62dc\u6258\u2014\u2014 \u8a00\u5f52\u6b63\u4f20&#xff0c;\u6574\u7bc7\u7b14\u8bb0\u5171\u5206\u4e3a\u5341\u7ae0&#xff0c;\u90fd\u662f\u535a\u4e3b\u5728\u51c6\u590725\u5e74\u84dd\u6865\u676f\u65f6\u6240\u5199&#xff0c;\u542c\u7684\u7f51\u8bfe\u662f\u8fd9\u4e2a&#xff0c;\u8bb2\u7684\u975e\u5e38\u597d&#xff0c;\u5f88\u9002\u5408\u96f6\u57fa\u7840\u901f\u6210&#xff0c;\u5982\u679c\u6709\u542c\u4e0d\u61c2\u7684\u53ef\u4ee5\u591a\u542c\u51e0\u904d https:\/\/\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/63736.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-01-22T02:16:25+00:00\" \/>\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=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/63736.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/63736.html\",\"name\":\"\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-01-22T02:16:25+00:00\",\"dateModified\":\"2026-01-22T02:16:25+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/63736.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/63736.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/63736.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8\"}]},{\"@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":"\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8 - \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\/63736.html","og_locale":"zh_CN","og_type":"article","og_title":"\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u524d\u8a00 \u535a\u4e3b\u5728\u5199\u7b14\u8bb0\u65f6\u51c6\u5907\u7684\u662f\u672c\u79d1\u751fB\u7ec4\u8d5b\u9053&#xff0c;\u5185\u5bb9\u53ef\u4f9b\u51c6\u5907\u540c\u6837\u8d5b\u9053\u53ca\u4ee5\u4e0b\u7684\u540c\u5b66\u53c2\u8003\u3002 \u5e0c\u671b\u5404\u4f4d\u540c\u5b66\u8499\u7684\u5168\u5bf9&#xff0c;\u8003\u7684\u5168\u4f1a\u3002 \u5982\u679c\u5bf9\u4f60\u6709\u5e2e\u52a9&#xff0c;\u53ef\u4ee5\u70b9\u8d5e\u8bc4\u8bba\u9f13\u52b1\u4e00\u4e0b\u535a\u4e3b\u5417&#xff1f;\u62dc\u6258\u62dc\u6258\u2014\u2014 \u8a00\u5f52\u6b63\u4f20&#xff0c;\u6574\u7bc7\u7b14\u8bb0\u5171\u5206\u4e3a\u5341\u7ae0&#xff0c;\u90fd\u662f\u535a\u4e3b\u5728\u51c6\u590725\u5e74\u84dd\u6865\u676f\u65f6\u6240\u5199&#xff0c;\u542c\u7684\u7f51\u8bfe\u662f\u8fd9\u4e2a&#xff0c;\u8bb2\u7684\u975e\u5e38\u597d&#xff0c;\u5f88\u9002\u5408\u96f6\u57fa\u7840\u901f\u6210&#xff0c;\u5982\u679c\u6709\u542c\u4e0d\u61c2\u7684\u53ef\u4ee5\u591a\u542c\u51e0\u904d https:\/\/","og_url":"https:\/\/www.wsisp.com\/helps\/63736.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-01-22T02:16:25+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/63736.html","url":"https:\/\/www.wsisp.com\/helps\/63736.html","name":"\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-01-22T02:16:25+00:00","dateModified":"2026-01-22T02:16:25+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/63736.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/63736.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/63736.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u84dd\u6865\u676fpython\u5907\u8d5b\u7b14\u8bb0\u4e4b\uff08\u4e00\uff09Python\u8bed\u6cd5\u57fa\u7840\u53ca\u7b97\u6cd5\u5165\u95e8"}]},{"@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\/63736","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=63736"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/63736\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=63736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=63736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=63736"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=63736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}