{"id":124420,"date":"2026-11-18T23:56:24","date_gmt":"2026-11-18T15:56:24","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/124420.html"},"modified":"2026-11-18T23:56:24","modified_gmt":"2026-11-18T15:56:24","slug":"ai%e5%ba%94%e7%94%a8-1-4python_%e5%87%bd%e6%95%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/124420.html","title":{"rendered":"AI\u5e94\u7528-1.4Python_\u51fd\u6570"},"content":{"rendered":"<h3>\u4e00\u3001\u51fd\u6570\u57fa\u7840<\/h3>\n<h5>1.\u4ec0\u4e48\u662f\u51fd\u6570&#xff1a;<\/h5>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u51fd\u6570\u662f\u7ec4\u7ec7\u597d\u7684\u3001\u53ef\u91cd\u590d\u4f7f\u7528\u7684\u3001\u7528\u6765\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u4ee3\u7801\u7247\u6bb5\u3002<\/p>\n<h5>2.\u51fd\u6570\u7684\u4f5c\u7528&#xff1a;<\/h5>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 &#xff08;1&#xff09;\u63d0\u9ad8\u4ee3\u7801\u590d\u7528\u6027<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 &#xff08;2&#xff09;\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3001\u53ef\u7ba1\u7406\u6027\u3001\u7ef4\u62a4\u6027<\/p>\n<h5>3.\u5b9a\u4e49\u51fd\u6570&#xff1a;<\/h5>\n<p>def \u51fd\u6570\u540d(\u53c2\u6570\u5217\u8868):<br \/>\n    &#034;&#034;&#034;\u51fd\u6570\u6587\u6863\u5b57\u7b26\u4e32&#xff08;\u8bf4\u660e\u4f5c\u7528&#xff09;&#034;&#034;&#034;<br \/>\n    \u51fd\u6570\u4f53\u4ee3\u7801<br \/>\n    return \u8fd4\u56de\u503c   # \u53ef\u9009&#xff0c;\u6ca1\u6709return\u9ed8\u8ba4\u8fd4\u56deNone<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6ce8\u610f&#xff1a;&#xff08;1&#xff09;\u51fd\u6570\u5b9a\u4e49\u65f6\u5982\u679c\u6709\u591a\u4e2a\u53c2\u6570&#xff0c;\u591a\u4e2a\u53c2\u6570\u4e4b\u95f4\u4f7f\u7528\u9017\u53f7\u201c &#xff0c; \u201d\u5206\u9694<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0&#xff08;2&#xff09;return \u8bed\u53e5\u53ea\u6709\u8fd4\u56de\u529f\u80fd&#xff0c;\u800c\u6ca1\u6709\u8f93\u51fa\u6253\u5370\u7684\u529f\u80fd&#xff0c;\u5982\u679c\u8981\u8f93\u51fa&#xff0c;\u9700\u8981\u7ed3\u5408print()\u51fd\u6570\u6765\u5b9e\u73b0<\/p>\n<h5>4.\u8c03\u7528\u51fd\u6570&#xff1a;<\/h5>\n<p>\u51fd\u6570\u540d(\u53c2\u6570)<\/p>\n<h5>5.\u7b80\u5355\u6848\u4f8b-\u51fd\u6570\u5b9a\u4e49&#043;\u8c03\u7528<\/h5>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u51fd\u6570\u5185\u4e0d\u786e\u5b9a\u7684\u6570\u636e&#xff1a;\u8bbe\u7f6e\u6210\u53c2\u6570\u8ba9\u5916\u90e8\u8fdb\u884c\u4f20\u9012<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u51fd\u6570\u7684\u6267\u884c\u7ed3\u679c&#xff1a;\u5728\u5916\u90e8\u5b9a\u4e49\u53d8\u91cf\u63a5\u6536<\/p>\n<p>&#034;&#034;&#034;<br \/>\n#\u51fd\u6570\u5b9a\u4e49<br \/>\n\u5b9a\u4e49\u8bed\u6cd5&#xff1a;<br \/>\n    def \u51fd\u6570\u540d\u79f0&#xff08;&#xff09;&#xff1a;      #\u65e0\u53c2\u65e0\u8fd4\u56de\u503c<br \/>\n        \u51fd\u6570\u4f53<br \/>\n    def \u51fd\u6570\u540d\u79f0&#xff08;\u53c2\u6570&#xff09;&#xff1a;   #\u6709\u53c2\u65e0\u8fd4\u56de\u503c<br \/>\n        \u51fd\u6570\u4f53<br \/>\n    def \u51fd\u6570\u540d\u79f0&#xff08;&#xff09;&#xff1a;      #\u65e0\u53c2\u6709\u8fd4\u56de\u503c<br \/>\n        \u51fd\u6570\u4f53<br \/>\n        return \u7ed3\u679c<br \/>\n    def \u51fd\u6570\u540d\u79f0&#xff08;\u53c2\u6570&#xff09;&#xff1a;   #\u6709\u53c2\u6709\u8fd4\u56de\u503c<br \/>\n        \u51fd\u6570\u4f53<br \/>\n        return \u7ed3\u679c<br \/>\n\u53c2\u6570\u548c\u8fd4\u56de\u7ed3\u679c\u5982\u4f55\u8bbe\u8ba1&#xff1a;<br \/>\n    \u770b\u9700\u6c42<\/p>\n<p>#\u51fd\u6570\u8c03\u7528<br \/>\n\u8c03\u7528\u8bed\u6cd5&#xff1a;<br \/>\n          \u51fd\u6570\u540d\u79f0&#xff08;&#xff09;        #\u65e0\u53c2\u65e0\u8fd4\u56de\u503c<br \/>\n          \u51fd\u6570\u540d\u79f0&#xff08;\u5b9e\u53c2&#xff09;    #\u65e0\u53c2\u65e0\u8fd4\u56de\u503c<br \/>\n    \u53d8\u91cf &#061; \u51fd\u6570\u540d\u79f0&#xff08;&#xff09;       #\u65e0\u53c2\u6709\u8fd4\u56de\u503c<br \/>\n    \u53d8\u91cf &#061; \u51fd\u6570\u540d\u79f0&#xff08;\u5b9e\u53c2&#xff09;    #\u6709\u53c2\u6709\u8fd4\u56de\u503c<br \/>\n&#034;&#034;&#034;<\/p>\n<p>#\u9700\u6c421&#xff1a;\u8bbe\u8ba1\u51fd\u6570\u8ba1\u7b9712345\u548c54321\u7684\u548c&#xff0c;\u5e76\u6253\u5370\u7ed3\u679c<br \/>\ndef func1():<br \/>\n    result &#061; 12345 &#043; 54321<br \/>\n    print(result)<br \/>\n#\u9700\u6c422&#xff1a;\u8bbe\u8ba1\u51fd\u6570\u5e76\u8ba1\u7b97\u4e24\u4e2a\u6570\u548c&#xff0c;\u5e76\u6253\u5370\u7ed3\u679c<br \/>\ndef func2(num1, num2):<br \/>\n    result &#061; num1 &#043; num2<br \/>\n    print(result)<br \/>\n#\u9700\u6c423&#xff1a;\u8bbe\u8ba1\u51fd\u6570\u8ba1\u7b9712345\u548c54321\u7684\u548c<br \/>\ndef func3():<br \/>\n    result &#061; 12345 &#043; 54321<br \/>\n    return result<br \/>\n#\u9700\u6c424&#xff1a;\u8bbe\u8ba1\u51fd\u6570\u5e76\u8ba1\u7b97\u4e24\u4e2a\u6570\u548c<br \/>\ndef func4(num1, num2):<br \/>\n    result &#061; num1 &#043; num2<br \/>\n    return result<\/p>\n<p>#\u9700\u6c425&#xff1a;\u8c03\u75284\u4e2a\u51fd\u6570<br \/>\nfunc1()<br \/>\nfunc2(123,456)<br \/>\nresult3 &#061; func3()<br \/>\nresult4 &#061; func4(123,456)<\/p>\n<h5>6.\u51fd\u6570\u7684\u8bf4\u660e\u6587\u6863<\/h5>\n<p>\u00a0 \u00a0 \u00a0 \u00a0&#xff08;1&#xff09; \u51fd\u6570\u8bf4\u660e\u6587\u6863\u662f\u5199\u5728\u51fd\u6570\u5f00\u5934&#xff0c;\u7528\u4e09\u4e2a\u5f15\u53f7\u5305\u88f9\u7684\u5b57\u7b26\u4e32&#xff0c;\u7528\u4e8e\u89e3\u91ca\u51fd\u6570\u7684\u529f\u80fd\u3001\u53c2\u6570\u3001\u8fd4\u56de\u503c\u7b49\u4fe1\u606f&#xff0c;\u65b9\u4fbf\u8c03\u7528\u8005\u6e05\u695a\u51fd\u6570\u7684\u5177\u4f53\u4f5c\u7528\u53ca\u7ec6\u8282<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 &#xff08;2&#xff09;\u51fd\u6570\u8bf4\u660e\u6587\u6863\u7684\u4f5c\u7528&#xff1a;\u65b9\u4fbf\u8c03\u7528\u8005\u6e05\u695a\u51fd\u6570\u7684\u5177\u4f53\u4f5c\u7528\u53ca\u7ec6\u8282&#xff0c;\u4f7f\u4ee3\u7801\u66f4\u5bb9\u6613\u7406\u89e3\u3001\u4f7f\u7528\u548c\u7ef4\u62a4<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&#xff08;3&#xff09;\u5982\u4f55\u6dfb\u52a0\u51fd\u6570\u8bf4\u660e\u6587\u6863&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u5199\u5728\u51fd\u6570\u5f00\u5934<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u7528\u4e09\u4e2a\u5f15\u53f7\u5305\u88f9\u7684\u5b57\u7b26\u4e32<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u7528\u4e8e\u89e3\u91ca\u51fd\u6570\u7684\u529f\u80fd\u3001\u53c2\u6570\u3001\u8fd4\u56de\u503c\u7b49\u4fe1\u606f<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 &#xff08;4&#xff09;\u5982\u4f55\u67e5\u770b\u51fd\u6570\u8bf4\u660e\u6587\u6863&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u65b9\u5f0f\u4e00&#xff1a;\u901a\u8fc7help\u51fd\u6570<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 help&#xff08;rectangle_area&#xff09;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u65b9\u5f0f\u4e8c&#xff1a;\u5728pycharm\u4e2d&#xff0c;\u9f20\u6807\u60ac\u6d6e\u5728\u51fd\u6570\u4e0a&#xff0c;\u81ea\u52a8\u5c55\u793a&#xff08;\u63a8\u8350&#xff09;<\/p>\n<p>#\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570&#xff1a;\u8ba1\u7b97\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u4e2d\u5143\u97f3\u5b57\u6bcd\u7684\u4e2a\u6570<br \/>\n&#034;&#034;&#034;<br \/>\n\u9700\u6c421&#xff1a;<br \/>\n    \u51fd\u6570\u540d&#xff1a;count<br \/>\n    \u53c2\u6570&#xff1a;\u9700\u8981&#xff0c;\u4f20\u9012\u7edf\u8ba1\u7684\u5b57\u7b26\u4e32\u53c2\u6570&#xff0c;count_str<br \/>\n    \u8fd4\u56de\u503c&#xff1a;\u9700\u8981&#xff0c;\u8fd4\u56de\u7edf\u8ba1\u7684\u4e2a\u6570<br \/>\n    \u529f\u80fd\u5b9e\u73b0&#xff1a;\u7565<br \/>\n&#034;&#034;&#034;<br \/>\ndef count(count_str):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u8ba1\u7b97\u4f20\u5165\u7684\u5b57\u7b26\u4e32\u4e2d\u5143\u97f3\u5b57\u6bcd\u7684\u4e2a\u6570<br \/>\n    :param count_str:<br \/>\n    :return:<br \/>\n    &#034;&#034;&#034;<br \/>\n    count &#061; 0<br \/>\n    for i in count_str:<br \/>\n        if i in &#034;aeiouAEIOU&#034;:<br \/>\n            count&#043;&#061;1<br \/>\n    return count<\/p>\n<p>count1 &#061; count(&#034;abandon&#034;)<br \/>\nprint(count1)<\/p>\n<p>#\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570&#xff1a;\u8ba1\u7b97\u4f20\u5165\u7684\u73ed\u7ea7\u5b66\u5458\u9ad8\u8003\u6210\u7ee9\u5217\u8868\u4e2d\u6700\u9ad8\u5206\u3001\u6700\u4f4e\u5206\u3001\u5e73\u5747\u5206<br \/>\n&#034;&#034;&#034;<br \/>\n\u9700\u6c422&#xff1a;<br \/>\n    \u51fd\u6570\u540d&#xff1a;count_score<br \/>\n    \u53c2\u6570&#xff1a;\u9700\u8981&#xff0c;\u4f20\u9012\u7edf\u8ba1\u7684\u5b57\u7b26\u4e32\u53c2\u6570&#xff0c;score_list<br \/>\n    \u8fd4\u56de\u503c&#xff1a;\u9700\u8981&#xff0c;\u8fd4\u56de\u7edf\u8ba1\u7684\u6700\u9ad8\u5206\u3001\u6700\u4f4e\u5206\u3001\u5e73\u5747\u5206(\u4ece\u4e94\u5927\u5bb9\u5668\u4e2d\u9009\u62e9\u5c01\u88c5\u591a\u4e2a\u7ed3\u679c&#xff0c;\u8fd4\u56de\u5bb9\u5668&#xff09;<br \/>\n    \u529f\u80fd\u5b9e\u73b0&#xff1a;\u7565<br \/>\n&#034;&#034;&#034;<br \/>\ndef count_score(score_list):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u8ba1\u7b97\u4f20\u5165\u7684\u73ed\u7ea7\u5b66\u5458\u9ad8\u8003\u6210\u7ee9\u5217\u8868\u4e2d\u6700\u9ad8\u5206\u3001\u6700\u4f4e\u5206\u3001\u5e73\u5747\u5206<br \/>\n    :param score_list:<br \/>\n    :return:<br \/>\n    &#034;&#034;&#034;<br \/>\n    max_score &#061; max(score_list)<br \/>\n    min_score &#061; min(score_list)<br \/>\n    avg_score &#061; sum(score_list)\/len(score_list)<br \/>\n    score &#061; {&#034;max&#034;:max_score,&#034;min&#034;:min_score,&#034;avg&#034;:avg_score}<br \/>\n    return score<\/p>\n<p>count_score1 &#061; count_score([88,99,66,77])<br \/>\nprint(count_score1)<\/p>\n<h2>\u4e8c\u3001\u51fd\u6570\u8fdb\u9636<\/h2>\n<h5>1.\u51fd\u6570\u2014\u53d8\u91cf\u4f5c\u7528\u57df<\/h5>\n<p>&#xff08;1&#xff09;\u6709\u54ea\u4e9b\u4f5c\u7528\u57df&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u2014\u2014 local &#xff08;\u5c40\u90e8&#xff09;&#xff1a;\u5728del\u51fd\u6570\u91cc\u9762\u521b\u5efa\u7684\u53d8\u91cf&#xff0c;\u5c31\u662f\u5c40\u90e8\u53d8\u91cf<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u2014\u2014 Enclosing &#xff08;\u5d4c\u5957\u5916\u5c42&#xff09;&#xff1a;\u51fd\u6570\u91cc\u9762\u518d\u5957\u4e00\u4e2a\u51fd\u6570&#xff08;\u5d4c\u5957\u51fd\u6570&#xff09;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u2014\u2014 Global &#xff08;\u5168\u5c40&#xff09;&#xff1a;\u76f4\u63a5\u5199\u5728\u51fd\u6570\u5916\u9762<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u2014\u2014 Built &#8211; in &#xff08;\u5185\u7f6e&#xff09;&#xff1a;Python\u81ea\u5e26\u7684\u540d\u5b57<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u6ce8\u610f&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u5168\u5c40\u53d8\u91cf&#xff1a;\u5728\u51fd\u6570\u3001\u63a8\u5bfc\u5f0f\u4e4b\u5916\u5b9a\u4e49\u7684\u53d8\u91cf&#xff0c;\u79f0\u4e4b\u4e3a\u5168\u5c40\u53d8\u91cf\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u5728\u6574\u4e2a\u6587\u4ef6\u4e2d&#xff08;\u5305\u62ec\u51fd\u6570\u5185&#xff09;\u90fd\u53ef\u4ee5\u4f7f\u7528&#xff08;\u901a\u5e38\u5b9a\u4e49\u5728\u6587\u4ef6\u7684\u9876\u90e8&#xff09;\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u5c40\u90e8\u53d8\u91cf&#xff1a;\u5728\u51fd\u6570\u3001\u63a8\u5bfc\u5f0f\u5185\u90e8\u5b9a\u4e49\u7684\u53d8\u91cf&#xff0c;\u79f0\u4e4b\u4e3a\u5c40\u90e8\u53d8\u91cf\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u53ea\u5728\u8be5\u51fd\u6570\u5185\u90e8\u4f7f\u7528\u5916\u90e8\u65e0\u6cd5\u8bbf\u95ee&#xff0c;\u6267\u884c\u5b8c\u6bd5\u540e\u4f1a\u81ea\u52a8\u9500\u6bc1\u5176\u5185\u90e8\u5c40\u90e8\u53d8\u91cf<\/p>\n<p>&#xff08;2&#xff09;\u4f5c\u7528\u57df\u7279\u70b9:<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u53d8\u91cf\u5728\u54ea\u5b9a\u4e49&#xff0c;\u5b83\u7684\u6d3b\u52a8\u8303\u56f4\u57fa\u672c\u5c31\u5728\u54ea<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u53e3\u8bc0&#xff1a;LEGB&#xff08;\u67e5\u53d8\u91cf\u7684\u5bfb\u627e\u987a\u5e8f&#xff09;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0Local&#xff08;\u5c40\u90e8&#xff09;&#8211;&gt;Enclosing&#xff08;\u5d4c\u5957\u5916\u5c42&#xff09;&#8211;&gt;\u00a0Global&#xff08;\u5168\u5c40&#xff09;&#8211;&gt; Built &#8211; in&#xff08;\u5185\u7f6e&#xff09;<\/p>\n<p>&#xff08;3&#xff09;\u5728\u5c40\u90e8\u4fee\u6539\u5168\u5c40\u53d8\u91cf&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 &lt;1&gt;\u9996\u5148&#xff0c;\u4f7f\u7528global\u4fee\u9970\u53d8\u91cf<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 global \u53d8\u91cf\u540d\u79f0<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 &lt;2&gt;\u544a\u77e5Python\u89e3\u91ca\u5668&#xff0c;\u5f53\u524d\u64cd\u4f5c\u7684\u662f\u5916\u90e8\u5168\u5c40\u7684\u53d8\u91cf&#xff0c;\u5f53\u524d\u4f4d\u7f6e\u4e0d\u8981\u91cd\u65b0\u521b\u5efa\u65b0\u7684\u53d8\u91cf&#xff0c;\u76f4\u63a5\u64cd\u4f5c\u5916\u90e8\u5168\u5c40\u53d8\u91cf<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u53d8\u91cf\u540d\u79f0 &#061; \u65b0\u7684\u503c<\/p>\n<p># \u5168\u5c40\u53d8\u91cf<br \/>\nnum &#061; 100<\/p>\n<p>def change_num():<br \/>\n    # \u58f0\u660e&#xff1a;\u4e0b\u9762\u64cd\u4f5c\u7684 num \u662f\u5168\u5c40\u53d8\u91cf<br \/>\n    global num<br \/>\n    num &#061; 200   # \u4fee\u6539\u5168\u5c40\u53d8\u91cf\u7684\u503c<br \/>\n    print(&#034;\u51fd\u6570\u5185\u90e8num&#xff1a;&#034;, num)<\/p>\n<p># \u8c03\u7528<br \/>\nchange_num()<br \/>\nprint(&#034;\u51fd\u6570\u5916\u90e8num&#xff1a;&#034;, num)<\/p>\n<h5 style=\"background-color:transparent\">2.\u51fd\u6570-\u53c2\u6570<\/h5>\n<p>&#xff08;1&#xff09;\u4f20\u53c2\u65b9\u5f0f<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u65b9\u5f0f\u4e00\u3001\u4f4d\u7f6e\u4f20\u53c2<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u8c03\u7528\u51fd\u6570\u65f6\u6839\u636e\u51fd\u6570\u5b9a\u4e49\u65f6\u7684\u4f4d\u7f6e\u6765\u4f20\u9012\u53c2\u6570<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u8981\u6c42&#xff1a;\u8c03\u7528\u51fd\u6570\u65f6\u53c2\u6570\u987a\u5e8f\u4e0e\u5b9a\u4e49\u51fd\u6570\u65f6\u53c2\u6570\u987a\u5e8f\u5b8c\u5168\u4e00\u81f4<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u65b9\u5f0f\u4e8c\u3001\u5173\u952e\u5b57\u4f20\u53c2<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u8c03\u7528\u51fd\u6570\u65f6\u4ee5\u51fd\u6570\u5b9a\u4e49\u65f6\u5f62\u53c2\u4f5c\u4e3a\u5173\u952e\u5b57&#xff0c;\u4ee5\u201c\u952e&#061;\u503c\u201d\u7684\u5f62\u5f0f\u6765\u4f20\u9012\u53c2\u6570&#xff08;\u4e0d\u8981\u6c42\u987a\u5e8f&#xff09;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u6ce8\u610f&#xff1a;\u5982\u679c\u4f4d\u7f6e\u53c2\u6570\u4e0e\u5173\u952e\u5b57\u53c2\u6570\u6df7\u7528&#xff0c;\u5173\u952e\u5b57\u53c2\u6570\u5fc5\u987b\u5728\u4f4d\u7f6e\u53c2\u6570\u4e4b\u540e&#xff08;\u5173\u952e\u5b57\u53c2\u6570\u4e4b\u95f4&#xff0c;\u6ca1\u6709\u987a\u5e8f\u8981\u6c42&#xff09;<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u9879\u4f4d\u7f6e\u53c2\u6570\u5173\u952e\u5b57\u53c2\u6570<\/tr>\n<tbody>\n<tr>\n<td>\u5199\u6cd5<\/td>\n<td>f(\u503c1, \u503c2, \u503c3)<\/td>\n<td>f(\u540d1&#061;\u503c1, \u540d2&#061;\u503c2)<\/td>\n<\/tr>\n<tr>\n<td>\u5bf9\u5e94\u4f9d\u636e<\/td>\n<td>\u4f4d\u7f6e\u987a\u5e8f<\/td>\n<td>\u53c2\u6570\u540d<\/td>\n<\/tr>\n<tr>\n<td>\u987a\u5e8f\u662f\u5426\u91cd\u8981<\/td>\n<td>\u2705 \u5fc5\u987b\u4e25\u683c\u5bf9\u5e94<\/td>\n<td>\u274c \u53ef\u4efb\u610f\u6392\u5217<\/td>\n<\/tr>\n<tr>\n<td>\u53ef\u8bfb\u6027<\/td>\n<td>\u5dee&#xff08;\u503c\u662f\u4ec0\u4e48\u8981\u9760\u731c&#xff09;<\/td>\n<td>\u5f3a&#xff08;\u4e00\u773c\u770b\u61c2&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u4ee3\u7801\u91cf<\/td>\n<td>\u7b80\u6d01<\/td>\n<td>\u7a0d\u7e41\u7410<\/td>\n<\/tr>\n<tr>\n<td>\u6613\u9519\u98ce\u9669<\/td>\n<td>\u9ad8&#xff08;\u987a\u5e8f\u9519\u5c31\u5168\u9519&#xff0c;\u4e14\u4e0d\u62a5\u9519&#xff09;<\/td>\n<td>\u4f4e&#xff08;\u540d\u5b57\u9519\u4f1a\u76f4\u63a5\u62a5\u9519&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u7ef4\u62a4\u6269\u5c55<\/td>\n<td>\u96be&#xff08;\u52a0\u53c2\u6570\u8981\u6539\u6240\u6709\u8c03\u7528\u5904&#xff09;<\/td>\n<td>\u6613&#xff08;\u53ea\u8865\u9700\u8981\u7684\u90a3\u4e00\u4e2a&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9002\u7528\u573a\u666f<\/td>\n<td>\u53c2\u6570 \u2264 3 \u4e2a&#xff0c;\u4e14\u987a\u5e8f\u81ea\u7136<\/td>\n<td>\u53c2\u6570\u8f83\u591a&#xff0c;\u6216\u7c7b\u578b \/ \u542b\u4e49\u6613\u6df7\u6dc6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#034;&#034;&#034;<br \/>\n\u8981\u6c42&#xff1a;\u638c\u63e1\u51fd\u6570\u8c03\u7528\u65f6&#xff0c;\u53c2\u6570\u4f20\u9012\u7684\u65b9\u5f0f<br \/>\n\u65b9\u5f0f\u4e00&#xff1a;\u4f4d\u7f6e\u53c2\u6570<br \/>\n       \u8c03\u7528\u51fd\u6570&#xff0c;\u4f20\u9012\u53c2\u6570\u65f6&#xff0c;\u53c2\u6570\u7684\u987a\u5e8f\u548c\u5b9a\u4e49\u51fd\u6570\u65f6\u5b8c\u5168\u4e00\u81f4<br \/>\n\u65b9\u5f0f\u4e8c&#xff1a;\u5173\u952e\u5b57\u53c2\u6570<br \/>\n       \u8c03\u7528\u53c2\u6570&#xff0c;\u4f20\u9012\u53c2\u6570\u65f6&#xff0c;\u53c2\u6570\u7684\u987a\u5e8f\u548c\u5b9a\u4e49\u51fd\u6570\u65f6\u53ef\u4ee5\u4e0d\u4e00\u81f4<br \/>\n       \u53c2\u6570\u540d\u79f0&#061;\u503c&#xff0c;\u53c2\u6570\u540d\u79f0&#061;\u503c<br \/>\n&#034;&#034;&#034;<br \/>\ndef show_info(name,age,gender,address):<br \/>\n    print(f&#034;name&#061;{name}&#034;)<br \/>\n    print(f&#034;age&#061;{age}&#034;)<br \/>\n    print(f&#034;gender&#061;{gender}&#034;)<br \/>\n    print(f&#034;address&#061;{address}&#034;)<\/p>\n<p>#\u8c03\u7528\u51fd\u6570&#xff1a;\u4f4d\u7f6e\u53c2\u6570\u65b9\u5f0f\u4f20\u9012\u53c2\u6570<br \/>\nshow_info(&#034;\u67da\u5b50&#034;,21,&#034;\u5973&#034;,&#034;\u676d\u5dde&#034;)<br \/>\nprint()<\/p>\n<p>#\u8c03\u7528\u51fd\u6570&#xff1a;\u5173\u952e\u5b57\u53c2\u6570\u65b9\u5f0f\u4f20\u9012\u53c2\u6570<br \/>\nshow_info(gender&#061;&#034;\u7537&#034;,age&#061;23,address&#061;&#034;\u676d\u5dde&#034;,name&#061;&#034;\u67e0\u6aac&#034;)<br \/>\nprint()<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u65b9\u5f0f\u4e09\u3001\u7f3a\u7701\u4f20\u53c2\/\u9ed8\u8ba4\u53c2\u6570<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u5728\u5b9a\u4e49\u51fd\u6570\u65f6&#xff0c;\u4e3a\u53c2\u6570\u63d0\u4f9b\u9ed8\u8ba4\u503c&#xff0c;\u8c03\u7528\u51fd\u6570\u65f6&#xff0c;\u53ef\u4ee5\u4e0d\u4f20\u9012\u6709\u9ed8\u8ba4\u503c\u7684\u53c2\u6570\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u6ce8\u610f&#xff1a;\u9ed8\u8ba4\u53c2\u6570\u5fc5\u987b\u653e\u5728\u6ca1\u6709\u9ed8\u8ba4\u503c\u7684\u53c2\u6570\u5217\u8868\u7684\u540e\u9762&#xff0c;\u4e00\u4e2a\u51fd\u6570\u5728\u5b9a\u4e49\u65f6\u662f\u53ef\u4ee5\u8bbe\u7f6e\u591a\u4e2a\u9ed8\u8ba4\u53c2\u6570\u7684\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u51fd\u6570\u8c03\u7528\u65f6&#xff0c;\u82e5\u679c\u4e3a\u9ed8\u8ba4\u53c2\u6570\u4f20\u9012\u4e86\u503c&#xff0c;\u5219\u4f1a\u4fee\u6539\u9ed8\u8ba4\u7684\u53c2\u6570\u503c&#xff1b;\u5982\u679c\u6ca1\u6709\u4f20\u9012\u8be5\u53c2\u6570&#xff0c;\u5219\u76f4\u63a5\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002<\/p>\n<p>def show_info(name,age,gender&#061;&#034;\u5973&#034;,address&#061;&#034;\u676d\u5dde&#034;):<br \/>\n    print(f&#034;name&#061;{name}&#034;)<br \/>\n    print(f&#034;age&#061;{age}&#034;)<br \/>\n    print(f&#034;gender&#061;{gender}&#034;)<br \/>\n    print(f&#034;address&#061;{address}&#034;)<\/p>\n<p>show_info(&#034;\u6843\u5b50&#034;,25,&#034;\u5973&#034;,&#034;\u4e0a\u6d77&#034;)<br \/>\nprint()<br \/>\nshow_info(&#034;\u67da\u5b50&#034;,25)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u65b9\u5f0f\u56db\u3001\u4e0d\u5b9a\u957f\u4f20\u53c2<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u4e0d\u5b9a\u957f\u53c2\u6570\u4e5f\u53eb\u53ef\u53d8\u53c2\u6570&#xff0c;\u7528\u4e8e\u51fd\u6570\u5b9a\u4e49\u53ca\u8c03\u7528\u65f6\u53c2\u6570\u4e2a\u6570\u4e0d\u786e\u5b9a&#xff08;0\u6216\u591a\u4e2a&#xff09;\u7684\u573a\u666f<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u7c7b\u578b&#xff1a;\u2014\u2014\u4f4d\u7f6e\u4f20\u9012<\/p>\n<p>&#034;&#034;&#034;<br \/>\n\u8bed\u6cd5&#xff1a;<br \/>\n    def \u51fd\u6570\u540d\u79f0&#xff08;*args):<br \/>\n        \u51fd\u6570\u4f53<br \/>\n        return \u7ed3\u679c<br \/>\n&#034;&#034;&#034;<br \/>\n#\u9700\u6c42&#xff1a;\u7edf\u8ba1\u4e00\u6279\u6570\u636e\u7684\u6700\u5927\u503c\u3001\u6700\u5c0f\u503c\u3001\u5e73\u5747\u503c<br \/>\n#\u4f20\u9012\u7684\u6240\u6709\u5b9e\u53c2\u90fd\u88abdatas\u53d8\u91cf\u6536\u96c6&#xff0c;\u5e76\u5c01\u88c5\u5230\u4e00\u4e2atuple\u4e2d<br \/>\ndef calc_data(*datas):   #datas\u53ea\u662f\u4e00\u4e2a\u5f62\u53c2\u540d\u79f0&#xff0c;\u53ef\u81ea\u884c\u5b9a\u4e49;\u5f62\u53c2\u524d\u52a0*\u8868\u793a\u7ec4\u5305&#xff08;\u5c06\u591a\u4e2a\u53c2\u6570\u5c01\u88c5\u5230\u4e00\u4e2a\u5bb9\u5668\u4e2d&#xff09;<br \/>\n    print(f&#034;\u5f62\u53c2\u7684\u7c7b\u578b\u662f{type(datas)}&#034;)<br \/>\n    print(f&#034;\u6700\u5c0f\u503c&#xff1a;{min(datas)}&#034;)<br \/>\n    print(f&#034;\u6700\u5927\u503c&#xff1a;{max(datas)}&#034;)<br \/>\n    print(f&#034;\u5e73\u5747\u503c&#xff1a;{type(datas)}&#034;)<br \/>\n    print()<\/p>\n<p>calc_data(1, 2, 3)<br \/>\ncalc_data(1, 2, 3,4,5)  #\u5b9e\u53c2&#xff1a;\u9700\u8981\u4f20\u9012\u591a\u4e2a\u4f4d\u7f6e\u53c2\u6570\u6570\u636e<br \/>\ncalc_data(1, 2)<br \/>\ncalc_data(1, 22, 3,44,5,66,7,88,9,100)<\/p>\n<p>t1 &#061; (12,3,4,5)<br \/>\ncalc_data(*t1,1,2,3)  #\u5b9e\u53c2\u524d\u52a0*\u8868\u793a\u89e3\u5305&#xff08;\u5c06\u5bb9\u5668\u4e2d\u7684\u591a\u4e2a\u6570\u636e&#xff0c;\u63d0\u53d6\u51fa\u6765\u4f5c\u4e3a\u591a\u4e2a\u53c2\u6570&#xff09;<\/p>\n<p>\u6ce8\u610f&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0(1)\u00a0\u4f20\u9012\u7684\u6240\u6709\u5339\u914d\u7684\u4f4d\u7f6e\u53c2\u6570\u90fd\u4f1a\u88abargs\u53d8\u91cf\u6536\u96c6&#xff0c;\u8fd9\u4e9b\u53c2\u6570\u4f1a\u5408\u5e76\u5c01\u88c5\u4e3a\u4e00\u4e2a\u5143\u7ec4&#xff0c;args\u662f\u5143\u7ec4\u7c7b\u578b&#xff08;\u6ce8\u610f\u5e76\u4e0d\u4f1a\u5c01\u88c5\u5173\u952e\u5b57\u53c2\u6570&#xff09;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 (2)args\u53ea\u662f\u7ea6\u5b9a\u4fd7\u6210\u7684\u53d8\u91cf\u540d&#xff0c;\u5e76\u4e0d\u662f\u5173\u952e\u5b57&#xff0c;\u8fd9\u91cc\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u5408\u6cd5\u7684\u53d8\u91cf\u540d&#xff08;eg&#xff1a;*data&#xff09;\u00a0 \u00a0<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u2014\u2014\u5173\u952e\u5b57\u4f20\u9012<\/p>\n<p>&#034;&#034;&#034;<br \/>\n\u8981\u6c42&#xff1a;\u770b\u61c2\u4e0d\u5b9a\u957f\u5173\u952e\u5b57\u53c2\u6570\u7684\u4e66\u5199\u5f62\u5f0f<br \/>\n\u8bed\u6cd5&#xff1a;<br \/>\n    def \u51fd\u6570\u540d\u79f0&#xff08;*args):<br \/>\n        \u51fd\u6570\u4f53<br \/>\n        return \u7ed3\u679c<br \/>\n&#034;&#034;&#034;<\/p>\n<p>#\u9700\u6c42&#xff1a;\u5c55\u793a\u7528\u6237\u4fe1\u606f<br \/>\n#\u4f20\u9012\u7684\u6240\u6709\u5b9e\u53c2\u90fd\u88abdatas\u53d8\u91cf\u6536\u96c6&#xff0c;\u5e76\u5c01\u88c5\u5230\u4e00\u4e2adict\u4e2d<br \/>\ndef show_info(**datas): #datas\u53ea\u662f\u4e00\u4e2a\u5f62\u53c2\u540d\u79f0&#xff0c;\u53ef\u4ee5\u81ea\u884c\u5b9a\u4e49<br \/>\n    print(f&#034;\u5f62\u53c2\u7684\u7c7b\u578b\u662f{type(datas)}&#034;)<br \/>\n    print(datas)<br \/>\n    print()<\/p>\n<p>show_info(name&#061;&#034;\u5f20\u4e09&#034;,age&#061;23,gender&#061;&#034;\u7537&#034;,tel&#061;&#034;18000000000000&#034;)<br \/>\nshow_info(name&#061;&#034;\u5f20\u4e09&#034;,gender&#061;&#034;\u7537&#034;,tel&#061;&#034;18000000000000&#034;)<br \/>\nshow_info(gender&#061;&#034;\u7537&#034;,tel&#061;&#034;18000000000000&#034;)<br \/>\nshow_info(gender&#061;&#034;\u7537&#034;)<\/p>\n<p>\u6ce8\u610f&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 &#xff08;1&#xff09;\u53c2\u6570\u662f\u4ee5\u201c\u952e&#061;\u503c\u201d\u5f62\u5f0f\u4f20\u9012\u7684\u5173\u952e\u5b57\u53c2\u6570&#xff0c;\u8fd9\u4e9b\u201c\u952e&#061;\u503c\u201d\u53c2\u6570\u90fd\u4f1a\u88abkwargs\u63a5\u53d7&#xff0c;\u5e76\u5408\u5e76\u5c01\u88c5\u4e3a\u4e00\u4e2a\u5b57\u5178\u7c7b\u578b\u3002<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 &#xff08;2&#xff09;kwargs\u53ea\u662f\u7ea6\u5b9a\u4fd7\u6210\u7684\u53d8\u91cf\u540d&#xff0c;\u5e76\u4e0d\u662f\u5173\u952e\u5b57&#xff0c;\u8fd9\u91cc\u53ef\u4ee5\u4f7f\u7528\u4efb\u4f55\u5408\u6cd5\u7684\u53d8\u91cf\u540d&#xff08;eg:**options&#xff09;<\/p>\n<p>def f(\u5fc5\u586b, \u53ef\u9009&#061;\u9ed8\u8ba4, *\u6570\u636e, \u4ec5\u5173\u952e\u5b57, **\u9009\u9879)<br \/>\n                  \u2191            \u2191          \u2191<br \/>\n              \u5355\u4e2a\u53ef\u7701      \u6253\u5305\u6210\u5143\u7ec4   \u6253\u5305\u6210\u5b57\u5178<br \/>\nf(1, 2, 3, 4, opt&#061;5, x&#061;6)<\/p>\n<h5 style=\"background-color:transparent\">3.\u53c2\u6570\u7c7b\u578b<\/h5>\n<p>&#xff08;1&#xff09;\u666e\u901a\u53c2\u6570<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0eg.\u00a0 \u00a0 \u00a0 \u00a0 float\u3001int\u3001bool\u3001str\u3001list\u3001set\u3001tuple\u3001dict\u7b49<\/p>\n<p>&#xff08;2&#xff09;\u7279\u6b8a\u53c2\u6570<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0def \u51fd\u6570\u540d\u79f0&#xff08;\u666e\u901a\u53c2\u6570&#xff0c;\u51fd\u6570\u53c2\u6570&#xff09;:<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u51fd\u6570\u53c2\u6570&#xff08;&#xff09;<\/p>\n<p>def add(a,b):<br \/>\n    return a&#043;b<br \/>\ndef sub(a,b):<br \/>\n    return a-b<\/p>\n<p>def calc(a,b,operator):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u5bf9\u4e24\u4e2a\u6570\u8fdb\u884c\u56db\u5219\u8fd0\u7b97\u64cd\u4f5c<br \/>\n    :param a: \u7b2c\u4e00\u4e2a\u6570\u636e<br \/>\n    :param b:\u7b2c\u4e8c\u4e2a\u6570\u636e<br \/>\n    :param operator: \u8fd0\u7b97\u7684\u51fd\u6570<br \/>\n    :return: \u8fd0\u7b97\u7ed3\u679c<br \/>\n    &#034;&#034;&#034;<br \/>\n    result &#061; operator(a,b)<br \/>\n    print(f&#034;\u8ba1\u7b97\u7ed3\u679c{result}&#034;)<\/p>\n<p>calc(10,20,add)<br \/>\ncalc(10,20,sub)<\/p>\n<h5 style=\"background-color:transparent\">4.\u533f\u540d\u51fd\u6570\u2014\u2014lambda<\/h5>\n<p>&#xff08;1&#xff09;\u6982\u5ff5&#xff1a;\u533f\u540d\u51fd\u6570\u6307\u7684\u662f\u6ca1\u6709\u540d\u79f0\u7684\u51fd\u6570&#xff0c;\u9700\u8981\u901a\u8fc7lambda\u8868\u8fbe\u5f0f\u6765\u58f0\u660e\u51fd\u6570&#xff0c;\u53ef\u4ee5\u7b80\u5316\u7b80\u5355\u51fd\u6570\u7684\u7f16\u5199&#xff08;\u5355\u884c\u8868\u8fbe\u5f0f&#xff09;<\/p>\n<p>&#xff08;2&#xff09;\u4e3a\u4ec0\u4e48\u4f7f\u7528\u533f\u540d\u51fd\u6570&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u2014\u2014\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570&#xff1a;\u51fd\u6570\u53ea\u4e34\u65f6\u4f7f\u7528\u4e00\u4e0b&#xff0c;\u53ea\u4f7f\u7528\u4e00\u6b21&#xff0c;\u51fd\u6570\u903b\u8f91\u4e0d\u590d\u6742<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u2014\u2014\u9700\u8981\u5c06\u6b64\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9\u53e6\u4e00\u4e2a\u51fd\u6570\u4f7f\u7528<\/p>\n<p>&#xff08;3&#xff09;lambda\u4f7f\u7528\u6761\u4ef6&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u6761\u4ef61&#xff1a;\u6709\u8fd4\u56de\u503c<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u6761\u4ef62&#xff1a;\u51fd\u6570\u4f53\u53ea\u6709\u4e00\u884c\u4ee3\u7801<\/p>\n<p>&#xff08;4&#xff09;\u8bed\u6cd5\u683c\u5f0f&#xff1a;<\/p>\n<p>lambda [\u53c2\u6570\u5217\u8868]:\u51fd\u6570\u4f53<\/p>\n<p>&#xff08;5&#xff09;\u6ce8\u610f&#xff1a;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u4f20\u9012\u7684\u662f\u51fd\u6570\u540d\u79f0&#xff0c;\u4e0d\u662f\u8c03\u7528\u51fd\u6570\u672c\u8eab&#xff1b;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u533f\u540d\u51fd\u6570\u4e2d\u5fc5\u987b\u662f\u4e00\u4e2a\u8868\u8fbe\u5f0f&#xff0c;\u4f1a\u81ea\u52a8\u5c06\u8868\u8fbe\u5f0f\u7684\u8fd0\u884c\u7ed3\u679c\u4f5c\u4e3a\u8fd4\u56de\u503c\u3002\u5982\u679c\u6267\u884c\u7684\u662fprint()\u8fd9\u7c7b\u65e0\u8fd4\u56de\u503c\u7684\u64cd\u4f5c&#xff0c;lambda\u4f1a\u8fd4\u56deNone&#xff1b;<\/p>\n<p>def calculation(x, y, operator):<br \/>\n    &#034;&#034;&#034;<br \/>\n    \u5bf9\u4e24\u4e2a\u6570\u8fdb\u884c\u56db\u5219\u8fd0\u7b97\u64cd\u4f5c<br \/>\n    :param x:  \u7b2c\u4e00\u4e2a\u6570\u636e<br \/>\n    :param y:  \u7b2c\u4e8c\u4e2a\u6570\u636e<br \/>\n    :param operator:  \u8fd0\u7b97\u7684\u51fd\u6570<br \/>\n    :return: \u8fd0\u7b97\u7ed3\u679c<br \/>\n    &#034;&#034;&#034;<br \/>\n    result &#061; operator(x, y)<br \/>\n    print(f&#039;\u8ba1\u7b97\u7ed3\u679c&#xff1a;{result}&#039;)<\/p>\n<p>&#034;&#034;&#034;<br \/>\n\u8981\u6c42&#xff1a;\u770b\u61c2\u666e\u901a\u53c2\u6570\u548c\u7279\u6b8a\u7c7b\u578b\u7684\u53c2\u6570<br \/>\n\u666e\u901a\u53c2\u6570&#xff1a;<br \/>\n    int , float , bool , None type<br \/>\n    str , list , tuple , set , dict<br \/>\n\u7279\u6b8a\u53c2\u6570&#xff1a;<br \/>\n    \u51fd\u6570<br \/>\n&#034;&#034;&#034;<br \/>\ncalculation(10, 20, lambda x, y: x &#043; y)<\/p>\n<p>calculation(1234, 1000, lambda x, y: x &#8211; y)<\/p>\n<p>&#034;&#034;&#034;<br \/>\n    \u5185\u7f6e\u51fd\u6570&#xff1a;map(fun,datas)<br \/>\n    \u4f5c\u7528&#xff1a;\u5bf9\u4e00\u6279\u6570\u636e\u8fdb\u884c\u6279\u5904\u7406<br \/>\n    \u53c2\u6570&#xff1a;1.\u52a0\u5de5\u5904\u7406\u7684\u51fd\u6570&#xff0c;2.\u5f85\u5904\u7406\u7684\u4e00\u6279\u6570\u636e<br \/>\n    \u8fd4\u56de&#xff1a;\u5904\u7406\u540e\u7684\u4e00\u6279\u7ed3\u679c\u5e8f\u5217\u6570\u636e&#xff0c;\u53ef\u4ee5\u4f7f\u7528list()\/tuple()\/set()\u8f6c\u6362\u6210\u5177\u4f53\u7684\u5bb9\u5668<br \/>\n&#034;&#034;&#034;<br \/>\ndef func(x):<br \/>\n    return x.replace(&#039;\u4f60\u5927\u7237&#039;,&#039;**&#039;)<\/p>\n<p># \u9700\u6c42&#xff1a;[&#034;\u4f60\u5927\u7237&#xff0c;\u8eab\u4f53\u6700\u8fd1\u597d\u5417&#xff1f;&#034;,&#034;\u83dc\u9e21&#xff0c;\u53bb\u4f60\u5927\u7237\u7684&#034;,&#034;\u4f1a\u73a9\u5417&#xff1f;\u4f60\u5927\u7237&#xff01;&#034;]&#xff0c;\u5bf9\u5217\u8868\u4e2d\u7684\u654f\u611f\u6570\u636e\u8fdb\u884c\u8131\u654f\u5904\u7406&#xff0c;\u628a\u4f60\u5927\u7237&#xff0c;\u66ff\u6362\u6210**<br \/>\ndata_list &#061; [&#034;\u4f60\u5927\u7237&#xff0c;\u8eab\u4f53\u6700\u8fd1\u597d\u5417&#xff1f;&#034;,&#034;\u83dc\u9e21&#xff0c;\u53bb\u4f60\u5927\u7237\u7684&#034;,&#034;\u4f1a\u73a9\u5417&#xff1f;\u4f60\u5927\u7237&#xff01;&#034;]<br \/>\nresult &#061; map(func, data_list)<br \/>\nprint(list(result))<\/p>\n<p>\u8865\u5145&#xff1a;map()\u51fd\u6570<\/p>\n<p>map(\u51fd\u6570, \u53ef\u8fed\u4ee3\u5bf9\u8c61)<\/p>\n<ul>\n<li>\u4f5c\u7528&#xff1a;\u628a\u53ef\u8fed\u4ee3\u5bf9\u8c61\u91cc\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20&#xff0c;\u4f9d\u6b21\u4f20\u7ed9\u8fd9\u4e2a\u51fd\u6570\u505a\u5904\u7406&#xff0c;\u8fd4\u56de\u4e00\u4e2a map \u5bf9\u8c61&#xff08;\u8fed\u4ee3\u5668&#xff09;<\/li>\n<li>\u7279\u70b9&#xff1a;\u61d2\u52a0\u8f7d&#xff0c;\u4e0d\u4f1a\u7acb\u523b\u7b97\u51fa\u5168\u90e8\u7ed3\u679c&#xff0c;\u9700\u8981\u7528 list() \u8f6c\u6210\u5217\u8868\u67e5\u770b<\/li>\n<\/ul>\n<p>\u4e00\u53e5\u8bdd&#xff1a;\u5bf9\u5e8f\u5217\u91cc\u6bcf\u4e00\u4e2a\u5143\u7d20\u6279\u91cf\u6267\u884c\u540c\u4e00\u4e2a\u51fd\u6570<\/p>\n<h5>5.\u9012\u5f52\u7b97\u6cd5<\/h5>\n<p>&#xff08;1&#xff09;\u8868\u73b0&#xff1a;\u51fd\u6570\u8c03\u7528\u51fd\u6570<\/p>\n<p>&#xff08;2&#xff09;\u573a\u666f&#xff1a;\u53d1\u73b0\u516c\u5f0f\u4e2d\u5b58\u5728\u51fd\u6570\u81ea\u5df1\u8c03\u7528\u81ea\u5df1\u7684\u60c5\u51b5&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u9012\u5f52\u7b97\u6cd5\u5b9e\u73b0<\/p>\n<p>&#xff08;3&#xff09;\u5b9e\u73b0\u6b65\u9aa4&#xff1a;\u627e\u9012\u5f52\u516c\u5f0f &#8211;&gt; \u5b9a\u4e49\u9012\u5f52\u51fd\u6570 &#8211;&gt; \u8bbe\u7f6e\u51fa\u53e3&#xff0c;\u907f\u514d\u6808\u5185\u5b58\u6ea2\u51fa<\/p>\n<p>&#034;&#034;&#034;<br \/>\n\u9012\u5f52\u7b97\u6cd5&#xff1a;\u51fd\u6570\u81ea\u5df1\u8c03\u7528\u81ea\u5df1<br \/>\n    def func1():<br \/>\n        func1()<br \/>\n\u6ce8\u610f&#xff1a;\u907f\u514d\u6808\u5185\u5b58\u6ea2\u51fa<\/p>\n<p>\u9012\u5f52\u7f16\u5199\u6d41\u7a0b&#xff1a;<br \/>\n    1.\u627e\u9012\u5f52\u516c\u793a<br \/>\n    2.\u5b9a\u4e49\u9012\u5f52\u51fd\u6570<br \/>\n    3.\u8bbe\u7f6e\u51fa\u53e3&#xff0c;\u907f\u514d\u6808\u5185\u5b58\u6ea2\u51fa<br \/>\n&#034;&#034;&#034;<br \/>\n# \u9700\u6c421&#xff1a;\u8ba1\u7b97\u4e00\u4e2a\u6570\u7684\u9636\u4e58<br \/>\ndef func1(n):<br \/>\n    # \u9012\u5f52\u7684\u51fa\u53e3<br \/>\n    if n &#061;&#061; 1:<br \/>\n        return 1<br \/>\n    return n*func1(n-1)<br \/>\nprint(func1(5))<\/p>\n<p># \u9700\u6c422&#xff1a;\u8ba1\u7b97\u4e00\u4e2a\u6570\u7684\u7d2f\u52a0\u548c<br \/>\ndef func2(n):<br \/>\n    # \u9012\u5f52\u7684\u51fa\u53e3<br \/>\n    if n &#061;&#061; 1:<br \/>\n        return 1<br \/>\n    return n&#043;func1(n-1)<br \/>\nprint(func2(5))<\/p>\n<h5>6.\u7c7b\u578b\u6ce8\u89e3<\/h5>\n<p>&#xff08;1&#xff09;\u76f8\u5173\u5b9a\u4e49<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u2014\u2014\u7c7b\u578b\u6ce8\u89e3&#xff1a;\u662fPython\u4e2d\u7684\u4e00\u79cd\u8bed\u6cd5\u7279\u6027&#xff0c;\u7528\u4e8e\u660e\u786e\u6807\u8bc6\u53d8\u91cf\u3001\u51fd\u6570\u53c2\u6570\u548c\u8fd4\u56de\u503c\u7684\u6570\u636e\u7c7b\u578b&#xff0c;\u4ece\u800c\u4f7f\u4ee3\u7801\u66f4\u6e05\u6670\u3001\u66f4\u5b89\u5168\u3001\u66f4\u6613\u7ef4\u62a4\u3002<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u2014\u2014\u7c7b\u578b\u63a8\u65ad&#xff1a;Python\u89e3\u91ca\u5668\u81ea\u52a8\u63a8\u65ad\u51fa\u53d8\u91cf\u3001\u51fd\u6570\u53c2\u6570\u548c\u8fd4\u56de\u503c\u7684\u6570\u636e\u7c7b\u578b\u7684\u80fd\u529b&#xff0c;\u800c\u65e0\u9700\u5f00\u53d1\u8005\u663e\u5f0f\u58f0\u660e\u3002<\/p>\n<p>&#xff08;2&#xff09;\u7c7b\u578b\u7684\u5199\u6cd5&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 -\u53d8\u91cf&#xff1a;<\/p>\n<p># \u57fa\u7840\u5199\u6cd5&#xff1a;\u53d8\u91cf\u540d: \u7c7b\u578b &#061; \u503c<br \/>\nname: str &#061; &#034;\u5c0f\u660e&#034;<br \/>\nage: int &#061; 20<br \/>\nscore: float &#061; 95.5<br \/>\nis_student: bool &#061; True<\/p>\n<p># \u5bb9\u5668\u7c7b\u578b\u6ce8\u89e3&#xff08;Python3.9&#043;\u53ef\u4ee5\u76f4\u63a5\u5199list&#xff09;<br \/>\nnums: list[int] &#061; [10, 20, 30]<br \/>\ninfo: dict[str, int] &#061; {&#034;\u8bed\u6587&#034;: 88, &#034;\u6570\u5b66&#034;: 92}<\/p>\n<p>print(name, age, nums)<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 -\u51fd\u6570&#xff1a;<\/p>\n<p># \u51fd\u6570&#xff1a;\u63a5\u6536\u4e24\u4e2aint&#xff0c;\u8fd4\u56deint<br \/>\ndef add(a: int, b: int) -&gt; int:<br \/>\n    return a &#043; b<\/p>\n<p># \u8c03\u7528<br \/>\nres &#061; add(3, 5)<br \/>\nprint(res)<\/p>\n<p># \u53e6\u4e00\u4e2a\u4f8b\u5b50&#xff1a;\u63a5\u6536\u5b57\u7b26\u4e32&#xff0c;\u8fd4\u56de\u5e03\u5c14\u503c<br \/>\ndef is_long(s: str) -&gt; bool:<br \/>\n    return len(s) &gt; 5<\/p>\n<p>print(is_long(&#034;hello&#034;))<\/p>\n<p>&#xff08;3&#xff09;\u5e38\u89c1\u7c7b\u578b\u7684\u5199\u6cd5<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u2014\u2014\u5355\u4e2a\u7c7b\u578b&#xff1a;int\u3001float\u3001bool\u3001str\u3001None\u3001list\u3001set\u3001tuple\u3001dict<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u2014\u2014\u591a\u4e2a\u7c7b\u578b&#xff1a;str | int | None<\/p>\n<p>&#xff08;4&#xff09;\u7c7b\u578b\u6ce8\u89e3\u7684\u597d\u5904<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 -\u4ee3\u7801\u7ed3\u6784\u66f4\u6e05\u6670\u3001\u4ee3\u7801\u903b\u8f91\u66f4\u5b89\u5168\u3001\u6613\u7ef4\u62a4<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 -\u66f4\u51c6\u786e\u7684\u4ee3\u7801\u81ea\u52a8\u63d0\u793a<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 -\u63d0\u524d\u53d1\u73b0\u4ee3\u7801\u6f5c\u5728\u95ee\u9898<\/p>\n<p>&#xff08;5&#xff09;\u4f7f\u7528\u573a\u666f<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 -Python\u662f\u52a8\u6001\u7c7b\u578b\u8bed\u8a00&#xff0c;\u6dfb\u52a0\u7684\u7c7b\u578b\u6ce8\u89e3\u53ea\u662f\u63d0\u793a&#xff0c;\u5e76\u4e0d\u662f\u5f3a\u5236\u7ea6\u675f<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 -\u7c7b\u578b\u63a8\u65ad&#xff1a;Python\u4f1a\u81ea\u52a8\u8fdb\u884c\u7c7b\u578b\u63a8\u65ad &#8211;&gt; \u5982\u679c\u5bf9\u53d8\u91cf\u76f4\u63a5\u8d4b\u503c\u3001\u53d8\u91cf\u8fd0\u7b97\u7b49\u573a\u666f<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 -\u7c7b\u578b\u6ce8\u89e3&#xff1a;\u51fd\u6570\u53c2\u6570\u3001\u8fd4\u56de\u503c&#xff0c;\u63a8\u8350\u4f7f\u7528\u7c7b\u578b\u6ce8\u89e3<\/p>\n<h5>7.\u6a21\u5757<\/h5>\n<p>\u4e86\u89e3\u5373\u53ef<\/p>\n<p>\u8865\u5145&#xff1a;\u7279\u6b8a\u53d8\u91cf<\/p>\n<p>__all__ &#061; [&#034;\u540d\u5b571&#034;, &#034;\u540d\u5b572&#034;, &#034;\u540d\u5b573&#034;]<\/p>\n<p>__all__ \u662f\u4e00\u4e2a\u5217\u8868&#xff0c;\u7528\u6765\u63a7\u5236 from \u6a21\u5757\u540d import * \u65f6&#xff0c;\u54ea\u4e9b\u540d\u5b57\u4f1a\u88ab\u5bfc\u5165&#xff08;\u767d\u540d\u5355&#xff09;\u3002<\/p>\n<p>\u53ea\u5bf9 import * \u751f\u6548&#xff01;import \u6a21\u5757\u3001from xxx import \u540d\u5b57 \u4e0d\u53d7\u5b83\u9650\u5236\u3002<\/p>\n<p>__name__&#xff1a;\u5224\u65ad\u6a21\u5757\u662f\u76f4\u63a5\u8fd0\u884c\u8fd8\u662f\u88ab\u5bfc\u5165&#xff0c;\u63a7\u5236\u4ee3\u7801\u662f\u5426\u6267\u884c \u53d6\u503c&#xff1a;__main__ , \u6a21\u5757\u540d\u79f0 if __name__ &#061;&#061; \u201c__main__\u201d: \u6d4b\u8bd5\u4ee3\u7801<\/p>\n<p>__name__ &#061;&#061; &#034;__main__&#034;<\/p>\n<h5>8.\u8f6f\u4ef6\u5305<\/h5>\n<p>\u5bfc\u5165\u5305\u65b9\u5f0f&#xff1a;<\/p>\n<table>\n<tr>\u5bfc\u5165\u8bed\u53e5\u5bfc\u5165\u5bf9\u8c61\u63a7\u5236\u767d\u540d\u5355\u4f7f\u7528\u65b9\u5f0f<\/tr>\n<tbody>\n<tr>\n<td>import \u5305\u540d.\u6a21\u5757\u540d<\/td>\n<td>\u6a21\u5757<\/td>\n<td>\u65e0<\/td>\n<td>\u5305\u540d.\u6a21\u5757\u540d.\u529f\u80fd<\/td>\n<\/tr>\n<tr>\n<td>from \u5305\u540d import \u6a21\u5757\u540d<\/td>\n<td>\u6a21\u5757<\/td>\n<td>\u65e0<\/td>\n<td>\u6a21\u5757\u540d.\u529f\u80fd<\/td>\n<\/tr>\n<tr>\n<td>from \u5305\u540d import *<\/td>\n<td>\u5305\u4e0b\u7684\u6a21\u5757<\/td>\n<td>\u5305\u7684__init__.py\u91cc\u7684__all__<\/td>\n<td>\u6a21\u5757\u540d.\u529f\u80fd<\/td>\n<\/tr>\n<tr>\n<td>from \u5305\u540d.\u6a21\u5757\u540d import \u529f\u80fd\u540d<\/td>\n<td>\u5355\u4e2a\u529f\u80fd&#xff08;\u7c7b \/ \u51fd\u6570&#xff09;<\/td>\n<td>\u65e0<\/td>\n<td>\u76f4\u63a5 \u529f\u80fd\u540d()<\/td>\n<\/tr>\n<tr>\n<td>from \u5305\u540d.\u6a21\u5757\u540d import *<\/td>\n<td>\u6a21\u5757\u5185\u7684\u529f\u80fd<\/td>\n<td>\u6a21\u5757 py \u6587\u4ef6\u91cc\u7684__all__<\/td>\n<td>\u76f4\u63a5 \u529f\u80fd\u540d()<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6ce8\u610f&#xff1a;\u6ce8\u610f&#xff1a;\u5728\u5305\u4e2d\u5bfc\u5165\u5f53\u524d\u5305\u4e2d\u7684\u6a21\u5757\u65f6&#xff0c;\u4e0d\u8981\u5fd8\u8bb0\u4f7f\u7528\u76f8\u5bf9\u8def\u5f84&#xff0c;\u4ece\u5f53\u524d\u5305\u4e2d\u83b7\u53d6\u529f\u80fd \u76f8\u5bf9\u8def\u5f84&#xff1a;from .\u6a21\u5757\u540d\u79f0<\/p>\n<p>            <span id=\"quality-guide-article-end\" aria-hidden=\"true\" style=\"display:block;height:1px;margin-bottom:-1px\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u51fd\u6570\u57fa\u78401.\u4ec0\u4e48\u662f\u51fd\u6570&#xff1a;\u51fd\u6570\u662f\u7ec4\u7ec7\u597d\u7684\u3001\u53ef\u91cd\u590d\u4f7f\u7528\u7684\u3001\u7528\u6765\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u4ee3\u7801\u7247\u6bb5\u30022.\u51fd\u6570\u7684\u4f5c\u7528&#xff1a;&#xff08;1&#xff09;\u63d0\u9ad8\u4ee3\u7801\u590d\u7528\u6027&#xff08;2&#xff09;\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3001\u53ef\u7ba1\u7406\u6027\u3001\u7ef4\u62a4\u60273.\u5b9a\u4e49\u51fd\u6570&#xff1a;def \u51fd\u6570\u540d(\u53c2\u6570\u5217\u8868):\\&#8221;\\&#8221;\\&#8221;\u51fd\u6570\u6587\u6863\u5b57\u7b26\u4e32&#xff08;\u8bf4\u660e\u4f5c\u7528&#xff09;\\&#8221;\\&#8221;\\&#8221;\u51fd\u6570\u4f53\u4ee3\u7801return \u8fd4\u56de\u503c   # \u53ef\u9009&#xff0c;\u6ca1\u6709return\u9ed8\u8ba4\u8fd4\u56deNone\u6ce8\u610f&#xff1a;<\/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":[66,1871,81,190],"topic":[],"class_list":["post-124420","post","type-post","status-publish","format-standard","hentry","category-server","tag-ai","tag-python","tag-190"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>AI\u5e94\u7528-1.4Python_\u51fd\u6570 - \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\/124420.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AI\u5e94\u7528-1.4Python_\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u51fd\u6570\u57fa\u78401.\u4ec0\u4e48\u662f\u51fd\u6570&#xff1a;\u51fd\u6570\u662f\u7ec4\u7ec7\u597d\u7684\u3001\u53ef\u91cd\u590d\u4f7f\u7528\u7684\u3001\u7528\u6765\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u4ee3\u7801\u7247\u6bb5\u30022.\u51fd\u6570\u7684\u4f5c\u7528&#xff1a;&#xff08;1&#xff09;\u63d0\u9ad8\u4ee3\u7801\u590d\u7528\u6027&#xff08;2&#xff09;\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3001\u53ef\u7ba1\u7406\u6027\u3001\u7ef4\u62a4\u60273.\u5b9a\u4e49\u51fd\u6570&#xff1a;def \u51fd\u6570\u540d(\u53c2\u6570\u5217\u8868):&quot;&quot;&quot;\u51fd\u6570\u6587\u6863\u5b57\u7b26\u4e32&#xff08;\u8bf4\u660e\u4f5c\u7528&#xff09;&quot;&quot;&quot;\u51fd\u6570\u4f53\u4ee3\u7801return \u8fd4\u56de\u503c  # \u53ef\u9009&#xff0c;\u6ca1\u6709return\u9ed8\u8ba4\u8fd4\u56deNone\u6ce8\u610f&#xff1a;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/124420.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-18T15:56:24+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=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124420.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/124420.html\",\"name\":\"AI\u5e94\u7528-1.4Python_\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-18T15:56:24+00:00\",\"dateModified\":\"2026-11-18T15:56:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/124420.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/124420.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124420.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AI\u5e94\u7528-1.4Python_\u51fd\u6570\"}]},{\"@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":"AI\u5e94\u7528-1.4Python_\u51fd\u6570 - \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\/124420.html","og_locale":"zh_CN","og_type":"article","og_title":"AI\u5e94\u7528-1.4Python_\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u51fd\u6570\u57fa\u78401.\u4ec0\u4e48\u662f\u51fd\u6570&#xff1a;\u51fd\u6570\u662f\u7ec4\u7ec7\u597d\u7684\u3001\u53ef\u91cd\u590d\u4f7f\u7528\u7684\u3001\u7528\u6765\u5b9e\u73b0\u7279\u5b9a\u529f\u80fd\u7684\u4ee3\u7801\u7247\u6bb5\u30022.\u51fd\u6570\u7684\u4f5c\u7528&#xff1a;&#xff08;1&#xff09;\u63d0\u9ad8\u4ee3\u7801\u590d\u7528\u6027&#xff08;2&#xff09;\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3001\u53ef\u7ba1\u7406\u6027\u3001\u7ef4\u62a4\u60273.\u5b9a\u4e49\u51fd\u6570&#xff1a;def \u51fd\u6570\u540d(\u53c2\u6570\u5217\u8868):\"\"\"\u51fd\u6570\u6587\u6863\u5b57\u7b26\u4e32&#xff08;\u8bf4\u660e\u4f5c\u7528&#xff09;\"\"\"\u51fd\u6570\u4f53\u4ee3\u7801return \u8fd4\u56de\u503c  # \u53ef\u9009&#xff0c;\u6ca1\u6709return\u9ed8\u8ba4\u8fd4\u56deNone\u6ce8\u610f&#xff1a;","og_url":"https:\/\/www.wsisp.com\/helps\/124420.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-18T15:56:24+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/124420.html","url":"https:\/\/www.wsisp.com\/helps\/124420.html","name":"AI\u5e94\u7528-1.4Python_\u51fd\u6570 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-18T15:56:24+00:00","dateModified":"2026-11-18T15:56:24+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/124420.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/124420.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/124420.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"AI\u5e94\u7528-1.4Python_\u51fd\u6570"}]},{"@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\/124420","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=124420"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/124420\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=124420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=124420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=124420"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=124420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}