{"id":3236,"date":"2023-04-03T17:53:34","date_gmt":"2023-04-03T09:53:34","guid":{"rendered":"http:\/\/cnliutz.uicp.io\/?p=3236"},"modified":"2023-04-03T17:53:35","modified_gmt":"2023-04-03T09:53:35","slug":"%e6%9e%81%e7%ae%80python-%e5%bf%85%e5%ba%94%e5%af%b9%e8%af%9dpython","status":"publish","type":"post","link":"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=3236","title":{"rendered":"\u6781\u7b80python-\u5fc5\u5e94\u5bf9\u8bddpython"},"content":{"rendered":"\n<p><a>python\u6982\u8ff0<\/a><a>python\u5173\u952e\u5b57<\/a><a>python\u7684\u8bed\u6cd5\u7ed3\u6784\u548c\u5e94\u7528<\/a><a>python\u5e38\u89c1\u8bed\u6cd5<\/a><a>python\u4e2d\u7684\u8fd0\u7b97\u7b26<\/a><a>python\u4e2d\u7684\u53d8\u91cf<\/a><a>python\u4e2d\u7684\u5b57\u7b26\u4e32<\/a><a>python\u4e2d\u7684\u5217\u8868<\/a><a>python\u4e2d\u7684\u5143\u7ec4\u3001\u793a\u4f8b<\/a><a>python \u4e2d\u7684\u5b57\u5178<\/a><a>python\u4e2d\u7684\u51fd\u6570<\/a><a>python\u4e2d\u7684\u6a21\u5757<\/a><a>python\u4e2d\u7684\u7c7b\u4e0e\u5bf9\u8c61<\/a><a>python\u6761\u4ef6\u8bed\u53e5\u548c\u5faa\u73af\u8bed\u53e5\u793a\u4f8b<\/a><a>python\u4e2d\u5982\u4f55\u8fdb\u884c\u6587\u4ef6\u6309\u64cd\u4f5c<\/a><a>Python\u4e2d\u5982\u4f55\u8fdb\u884c\u5f02\u5e38\u5904\u7406\uff1f<\/a><a>\u5e38\u89c1\u9519\u8bef<\/a><a>Python\u4e2d\u5982\u4f55\u8c03\u8bd5\u4ee3\u7801\uff1f<\/a><\/p>\n\n\n\n<h1 class=\"wp-block-heading\">python\u6982\u8ff0<\/h1>\n\n\n\n<p>[1]: <a href=\"https:\/\/zhuanlan.zhihu.com\/p\/57790620\">https:\/\/zhuanlan.zhihu.com\/p\/57790620<\/a> &#8220;Python-\u6982\u8ff0 &#8211; \u77e5\u4e4e&#8221; [2]: <a href=\"https:\/\/baike.baidu.com\/item\/Python\/407313\">https:\/\/baike.baidu.com\/item\/Python\/407313<\/a> &#8220;Python\uff08\u8ba1\u7b97\u673a\u7f16\u7a0b\u8bed\u8a00\uff09_\u767e\u5ea6\u767e\u79d1&#8221; [3]: <a href=\"https:\/\/zhuanlan.zhihu.com\/p\/35446551\">https:\/\/zhuanlan.zhihu.com\/p\/35446551<\/a> &#8220;Python \u8bed\u8a00\u4ecb\u7ecd &#8211; \u77e5\u4e4e&#8221; [4]: <a href=\"https:\/\/www.runoob.com\/python\/python-intro.html\">https:\/\/www.runoob.com\/python\/python-intro.html<\/a> &#8220;Python \u7b80\u4ecb | \u83dc\u9e1f\u6559\u7a0b&#8221; [5]: <a href=\"https:\/\/zhuanlan.zhihu.com\/p\/169624095\">https:\/\/zhuanlan.zhihu.com\/p\/169624095<\/a> &#8220;Python\u7b80\u4ecb\u53ca\u53d1\u5c55\u5386\u53f2 &#8211; \u77e5\u4e4e&#8221; \u4f60\u597d\uff0c\u8fd9\u662fBing\u3002? Python\u662f\u4e00\u79cd\u9ad8\u7ea7\uff0c\u89e3\u91ca\uff0c\u4ea4\u4e92\u5f0f\u548c\u9762\u5411\u5bf9\u8c61\u7684\u811a\u672c\u8bed\u8a00<sup>1^<\/sup>[1] <sup>2^<\/sup>[2]\u3002\u5b83\u7684\u8bbe\u8ba1\u5177\u6709\u9ad8\u53ef\u8bfb\u6027\uff0c\u4f7f\u7528\u82f1\u8bed\u5173\u952e\u8bcd\u548c\u7b80\u6d01\u7684\u8bed\u6cd5\u7ed3\u6784<sup>1^<\/sup>[1] <sup>3^<\/sup>[4]\u3002Python\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8303\u5f0f\uff0c\u5982\u8fc7\u7a0b\u5f0f\u3001\u51fd\u6570\u5f0f\u3001\u9762\u5411\u5bf9\u8c61\u548c\u5143\u7f16\u7a0b<sup>2^<\/sup>[2]\u3002Python\u8fd8\u6709\u4e30\u5bcc\u7684\u6807\u51c6\u5e93\u548c\u7b2c\u4e09\u65b9\u5e93\uff0c\u63d0\u4f9b\u4e86\u5404\u79cd\u529f\u80fd\u548c\u5e94\u7528\u9886\u57df<sup>2^<\/sup>[2] <sup>3^<\/sup>[4]\u3002 Python\u7531\u8377\u5170\u6570\u5b66\u5bb6\u5409\u591a\u00b7\u8303\u7f57\u82cf\u59c6\u4e8e1990\u5e74\u4ee3\u521d\u8bbe\u8ba1\uff0c\u4f5c\u4e3a\u4e00\u95e8\u53eb\u505aABC\u8bed\u8a00\u7684\u66ff\u4ee3\u54c1<sup>2^<\/sup>[2]\u3002Python\u7684\u540d\u5b57\u6765\u6e90\u4e8e\u82f1\u56fd\u559c\u5267\u56e2\u4f53\u201c\u8499\u63d0\u00b7\u6d3e\u68ee\u201d\u7684\u98de\u884c\u9a6c\u620f\u56e2<sup>4^<\/sup>[5]\u3002Python\u76ee\u524d\u6709\u4e24\u4e2a\u4e3b\u8981\u7248\u672c\uff0c\u5206\u522b\u662fPython 2\u548cPython 3\uff0c\u5b83\u4eec\u4e4b\u95f4\u6709\u4e00\u4e9b\u4e0d\u517c\u5bb9\u7684\u53d8\u5316<sup>5^<\/sup>[3]\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">python\u5173\u952e\u5b57<\/h1>\n\n\n\n<p>[<strong>1<\/strong>] &nbsp;https:\/\/juejin.cn\/post\/6984229567380586504&nbsp;Python \u5173\u952e\u5b57\u3001\u6807\u8bc6\u7b26\u548c\u53d8\u91cf\uff5cPython \u4e3b\u9898\u6708 &#8211; \u6398\u91d1<\/p>\n\n\n\n<p>[<strong>2<\/strong>] &nbsp;https:\/\/zhuanlan.zhihu.com\/p\/35869998&nbsp;Python \u5173\u952e\u5b57 &#8211; \u77e5\u4e4e<\/p>\n\n\n\n<p>[<strong>3<\/strong>] &nbsp;https:\/\/www.w3school.com.cn\/python\/ref_keyword_is.asp&nbsp;Python is \u5173\u952e\u5b57<\/p>\n\n\n\n<p><a href=\"https:\/\/www.w3school.com.cn\/python\/python_ref_keywords.asp\">4<\/a>\u5173\u952e\u5b57<\/p>\n\n\n\n<p><a href=\"%20https:\/\/www.runoob.com\/python3\/python-with.html\">5<\/a> &#8220;Python with \u5173\u952e\u5b57 |<\/p>\n\n\n\n<p>\u83dc\u9e1f\u6559\u7a0b&#8221; Python\u5173\u952e\u5b57\u662f\u4e00\u7ec4\u4fdd\u7559\u7684\u7f16\u7a0b\u672f\u8bed\uff0c\u7528\u4e8e\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c<sup>1^<\/sup>[1]\u3002Python\u4e2d\u670935\u4e2a\u5173\u952e\u5b57\uff0c\u6bcf\u4e2a\u90fd\u6709\u4e0d\u540c\u7684\u7528\u9014\u548c\u542b\u4e49<sup>2^<\/sup>[2]\u3002\u5b83\u4eec\u4ee3\u8868\u4e86Python\u7a0b\u5e8f\u7684\u8bed\u6cd5\u548c\u7ed3\u6784\uff0c\u4e0d\u80fd\u7528\u4f5c\u53d8\u91cf\u540d\u3001\u51fd\u6570\u540d\u6216\u5176\u4ed6\u6807\u8bc6\u7b26<sup>1^<\/sup>[1] <sup>3^<\/sup>[4]\u3002 \u4f60\u53ef\u4ee5\u4f7f\u7528<code>import keyword<\/code>\u548c<code>keyword.kwlist<\/code>\u6765\u83b7\u53d6Python\u5173\u952e\u5b57\u7684\u5217\u8868<sup>2^<\/sup>[2]\u3002\u4e00\u4e9b\u5e38\u89c1\u7684\u5173\u952e\u5b57\u6709\uff1a &#8211; <code>and<\/code>, <code>or<\/code>, <code>not<\/code>: \u903b\u8f91\u8fd0\u7b97\u7b26 &#8211; <code>as<\/code>: \u521b\u5efa\u522b\u540d &#8211; <code>assert<\/code>: \u7528\u4e8e\u8c03\u8bd5 &#8211; <code>break<\/code>: \u8df3\u51fa\u5faa\u73af &#8211; <code>class<\/code>: \u5b9a\u4e49\u7c7b &#8211; <code>def<\/code>: \u5b9a\u4e49\u51fd\u6570 &#8211; <code>del<\/code>: \u5220\u9664\u5bf9\u8c61 &#8211; <code>if<\/code>, <code>elif<\/code>, <code>else<\/code>: \u6761\u4ef6\u5224\u65ad &#8211; <code>import<\/code>, <code>from<\/code>: \u5bfc\u5165\u6a21\u5757 &#8211; <code>is<\/code>: \u6d4b\u8bd5\u5bf9\u8c61\u662f\u5426\u76f8\u540c &#8211; <code>with<\/code>: \u7b80\u5316\u5f02\u5e38\u5904\u7406\u548c\u8d44\u6e90\u7ba1\u7406<sup>4^<\/sup>[3] <sup>5^<\/sup>[5]<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">python\u7684\u8bed\u6cd5\u7ed3\u6784\u548c\u5e94\u7528<\/h1>\n\n\n\n<p>Python\u662f\u4e00\u79cd\u9ad8\u7ea7\u7f16\u7a0b\u8bed\u8a00\uff0c\u5177\u6709\u7b80\u5355\u6613\u5b66\u3001\u4ee3\u7801\u53ef\u8bfb\u6027\u9ad8\u3001\u5f00\u53d1\u6548\u7387\u9ad8\u7b49\u7279\u70b9\u3002Python\u7684\u8bed\u6cd5\u7ed3\u6784\u548c\u5e94\u7528\u975e\u5e38\u5e7f\u6cdb\uff0c\u5305\u62ec\u4f46\u4e0d\u9650\u4e8e\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.runoob.com\/python\/python-basic-syntax.html\">Python\u7684\u57fa\u7840\u8bed\u6cd5\u5305\u62ec\u53d8\u91cf\u3001\u6570\u636e\u7c7b\u578b\u3001\u8fd0\u7b97\u7b26\u3001\u6761\u4ef6\u8bed\u53e5\u3001\u5faa\u73af\u8bed\u53e5\u7b49<\/a><a href=\"https:\/\/www.runoob.com\/python\/python-basic-syntax.html\">1<\/a>\u3002<\/li>\n\n\n\n<li><a href=\"https:\/\/www.runoob.com\/python\/python-functions.html\">Python\u7684\u51fd\u6570\u662f\u7ec4\u7ec7\u597d\u7684\uff0c\u53ef\u91cd\u590d\u4f7f\u7528\u7684\uff0c\u7528\u6765\u5b9e\u73b0\u5355\u4e00\u6216\u76f8\u5173\u8054\u529f\u80fd\u7684\u4ee3\u7801\u6bb5\u3002\u51fd\u6570\u80fd\u63d0\u9ad8\u5e94\u7528\u7684\u6a21\u5757\u6027\u548c\u4ee3\u7801\u7684\u91cd\u590d\u5229\u7528\u7387<\/a><a href=\"https:\/\/www.runoob.com\/python\/python-functions.html\">2<\/a>\u3002<\/li>\n\n\n\n<li><a href=\"https:\/\/www.runoob.com\/python\/python-basic-syntax.html\">Python\u652f\u6301\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\uff0c\u5305\u62ec\u7c7b\u3001\u5bf9\u8c61\u3001\u7ee7\u627f\u3001\u591a\u6001\u7b49<\/a><a href=\"https:\/\/www.runoob.com\/python\/python-basic-syntax.html\">1<\/a>\u3002<\/li>\n\n\n\n<li><a href=\"https:\/\/www.runoob.com\/python\/python-intro.html\">Python\u53ef\u4ee5\u5904\u7406\u5404\u79cd\u7c7b\u578b\u7684\u6570\u636e\uff0c\u5305\u62ec\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u3001\u5217\u8868\u3001\u5143\u7ec4\u3001\u5b57\u5178\u7b49<\/a><a href=\"https:\/\/www.runoob.com\/python\/python-intro.html\">3<\/a>\u3002<\/li>\n\n\n\n<li><a href=\"https:\/\/www.runoob.com\/python\/python-basic-syntax.html\">Python\u53ef\u4ee5\u8fdb\u884c\u6587\u4ef6\u64cd\u4f5c\uff0c\u5305\u62ec\u8bfb\u53d6\u6587\u4ef6\u548c\u5199\u5165\u6587\u4ef6<\/a><a href=\"https:\/\/www.runoob.com\/python\/python-basic-syntax.html\">1<\/a>\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">python\u5e38\u89c1\u8bed\u6cd5<\/h3>\n\n\n\n<p>Python\u4e2d\u8fd8\u6709\u5f88\u591a\u5e38\u7528\u8bed\u6cd5\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u53d8\u91cf\uff1a\u7528\u4e8e\u5b58\u50a8\u6570\u636e\uff0c\u53ef\u4ee5\u662f\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u3001\u5217\u8868\u7b49\u3002<\/li>\n\n\n\n<li>\u6570\u636e\u7c7b\u578b\uff1a\u5305\u62ec\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u3001\u5217\u8868\u3001\u5143\u7ec4\u3001\u5b57\u5178\u7b49\u3002<\/li>\n\n\n\n<li>\u8fd0\u7b97\u7b26\uff1a\u5305\u62ec\u7b97\u672f\u8fd0\u7b97\u7b26\u3001\u6bd4\u8f83\u8fd0\u7b97\u7b26\u3001\u903b\u8f91\u8fd0\u7b97\u7b26\u7b49\u3002<\/li>\n\n\n\n<li>\u6761\u4ef6\u8bed\u53e5\uff1a\u5305\u62ecif\u8bed\u53e5\u548cif-else\u8bed\u53e5\uff0c\u7528\u4e8e\u6839\u636e\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u7684\u4ee3\u7801\u5757\u3002<\/li>\n\n\n\n<li>\u5faa\u73af\u8bed\u53e5\uff1a\u5305\u62ecfor\u5faa\u73af\u548cwhile\u5faa\u73af\uff0c\u7528\u4e8e\u91cd\u590d\u6267\u884c\u4ee3\u7801\u5757\u3002<\/li>\n\n\n\n<li>\u51fd\u6570\uff1a\u7528\u4e8e\u5c01\u88c5\u4e00\u6bb5\u4ee3\u7801\uff0c\u53ef\u4ee5\u91cd\u590d\u4f7f\u7528\u3002<\/li>\n\n\n\n<li>\u6a21\u5757\uff1a\u7528\u4e8e\u7ec4\u7ec7\u4ee3\u7801\uff0c\u53ef\u4ee5\u5c06\u4ee3\u7801\u5206\u6210\u591a\u4e2a\u6587\u4ef6\u3002<\/li>\n\n\n\n<li>\u5f02\u5e38\u5904\u7406\uff1a\u7528\u4e8e\u5904\u7406\u7a0b\u5e8f\u8fd0\u884c\u65f6\u51fa\u73b0\u7684\u9519\u8bef\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">python\u4e2d\u7684\u8fd0\u7b97\u7b26<\/h3>\n\n\n\n<p>\u4ee5\u4e0b\u662fPython\u4e2d\u7684\u8fd0\u7b97\u7b26\u4e3e\u4f8b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u7b97\u672f\u8fd0\u7b97\u7b26\uff1a+\uff0c-\uff0c*\uff0c\/\uff0c%\uff0c**\uff0c\/\/<\/li>\n\n\n\n<li>\u6bd4\u8f83\uff08\u5173\u7cfb\uff09\u8fd0\u7b97\u7b26\uff1a==\uff0c!=\uff0c&gt;\uff0c&lt;\uff0c&gt;=\uff0c&lt;=<\/li>\n\n\n\n<li>\u8d4b\u503c\u8fd0\u7b97\u7b26\uff1a=\uff0c+=\uff0c-=\uff0c*=\uff0c\/=\uff0c%=\uff0c**=\uff0c\/\/=<\/li>\n\n\n\n<li>\u903b\u8f91\u8fd0\u7b97\u7b26\uff1aand\uff0cor\uff0cnot<\/li>\n\n\n\n<li>\u4f4d\u8fd0\u7b97\u7b26\uff1a&amp;\uff0c|\uff0c^\uff0c~\uff0c&lt;&lt;\uff0c&gt;&gt;<\/li>\n\n\n\n<li>\u6210\u5458\u8fd0\u7b97\u7b26\uff1ain\uff0cnot in<\/li>\n\n\n\n<li>\u8eab\u4efd\u8fd0\u7b97\u7b26\uff1ais\uff0cis not<\/li>\n\n\n\n<li>\u8fd0\u7b97\u7b26\u4f18\u5148\u7ea7<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">python\u4e2d\u7684\u53d8\u91cf<\/h3>\n\n\n\n<p>Python\u4e2d\u7684\u53d8\u91cf\u662f\u7528\u6765\u5b58\u50a8\u6570\u636e\u7684\uff0c\u53ef\u4ee5\u662f\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u3001\u5217\u8868\u3001\u5143\u7ec4\u3001\u5b57\u5178\u7b49\u7c7b\u578b\u3002\u5728Python\u4e2d\uff0c\u53d8\u91cf\u7684\u7c7b\u578b\u662f\u52a8\u6001\u7684\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u53d8\u91cf\u7684\u7c7b\u578b\u662f\u5728\u8fd0\u884c\u65f6\u786e\u5b9a\u7684](<a href=\"https:\/\/blog.csdn.net\/fengdu78\/article\/details\/116617923\">https:\/\/blog.csdn.net\/fengdu78\/article\/details\/116617923<\/a>)<a href=\"https:\/\/blog.csdn.net\/fengdu78\/article\/details\/116617923\">1<\/a><a href=\"https:\/\/www.runoob.com\/python\/python-variable-types.html\">2<\/a>\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/fengdu78\/article\/details\/116617923\">Python\u4e2d\u7684\u53d8\u91cf\u540d\u53ef\u4ee5\u6307\u4ee3\u53d8\u91cf\u3001\u51fd\u6570\u3001\u7c7b\u3001\u5bf9\u8c61\u7b49\u3002\u6bcf\u4e2a\u5bf9\u8c61\u90fd\u6709\u4e00\u4e2a\u53d8\u91cf\u540d\u6307\u5411\uff0c\u66f4\u51c6\u786e\u8bf4\u662f\u7ed1\u5b9a\u3002Python\u4e2d\u7684\u53d8\u91cf\u540d\u4e0d\u9700\u8981\u58f0\u660e\uff0c\u53ea\u9700\u8981\u5728\u4f7f\u7528\u524d\u8d4b\u503c\u5373\u53ef<\/a><a href=\"https:\/\/blog.csdn.net\/fengdu78\/article\/details\/116617923\">1<\/a><a href=\"https:\/\/www.w3school.com.cn\/python\/python_variables.asp\">3<\/a>\u3002<\/p>\n\n\n\n<p>Python\u4e2d\u7684\u53d8\u91cf\u547d\u540d\u89c4\u5219\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u53d8\u91cf\u540d\u5fc5\u987b\u4ee5\u5b57\u6bcd\u6216\u4e0b\u5212\u7ebf\u5b57\u7b26\u5f00\u5934\uff1b<\/li>\n\n\n\n<li>\u53d8\u91cf\u540d\u79f0\u4e0d\u80fd\u4ee5\u6570\u5b57\u5f00\u5934\uff1b<\/li>\n\n\n\n<li>\u53d8\u91cf\u540d\u53ea\u80fd\u5305\u542b\u5b57\u6bcd\u6570\u5b57\u5b57\u7b26\u548c\u4e0b\u5212\u7ebf\uff08A-z\u30010-9 \u548c _\uff09\uff1b<\/li>\n\n\n\n<li><a href=\"https:\/\/www.w3school.com.cn\/python\/python_variables.asp\">\u53d8\u91cf\u540d\u79f0\u533a\u5206\u5927\u5c0f\u5199\uff08age\u3001Age \u548c AGE \u662f\u4e09\u4e2a\u4e0d\u540c\u7684\u53d8\u91cf\uff09<\/a><a href=\"https:\/\/www.w3school.com.cn\/python\/python_variables.asp\">3<\/a>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">python\u4e2d\u7684\u5b57\u7b26\u4e32<\/h3>\n\n\n\n<p><a href=\"https:\/\/www.w3school.com.cn\/python\/python_strings.asp\">Python\u4e2d\u7684\u5b57\u7b26\u4e32\u662f\u8868\u793aUnicode\u5b57\u7b26\u7684\u5b57\u8282\u6570\u7ec4\u3002Python\u6ca1\u6709\u5b57\u7b26\u6570\u636e\u7c7b\u578b\uff0c\u5355\u4e2a\u5b57\u7b26\u5c31\u662f\u957f\u5ea6\u4e3a1\u7684\u5b57\u7b26\u4e32\u3002\u5728Python\u4e2d\uff0c\u5b57\u7b26\u4e32\u53ef\u4ee5\u4f7f\u7528\u5f15\u53f7\uff08&#8217;\u6216&#8221;\uff09\u6765\u521b\u5efa\u3002Python\u4e2d\u7684\u5b57\u7b26\u4e32\u53ef\u4ee5\u8fdb\u884c\u62fc\u63a5\u3001\u8bbf\u95ee\u3001\u5224\u65ad\u5b50\u4e32\u662f\u5426\u5728\u5df2\u77e5\u7684\u5b57\u7b26\u4e32\u4e2d\u7b49\u64cd\u4f5c\u3002Python\u4e2d\u7684\u5b57\u7b26\u4e32\u8fd8\u6709\u4e00\u4e9b\u5185\u7f6e\u51fd\u6570\uff0c\u5982len()\u3001upper()\u3001lower()\u7b49\uff0c\u53ef\u4ee5\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884c\u64cd\u4f5c<\/a><a href=\"https:\/\/bing.com\/search?q=Python%E5%AD%97%E7%AC%A6%E4%B8%B2\">1<\/a><a href=\"https:\/\/www.w3school.com.cn\/python\/python_strings.asp\">2<\/a><a href=\"https:\/\/blog.csdn.net\/Soinice\/article\/details\/109330172\">3<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">python\u4e2d\u7684\u5217\u8868<\/h3>\n\n\n\n<p>[Python\u4e2d\u7684\u5217\u8868\u662f\u4e00\u79cd\u6709\u5e8f\u4e14\u53ef\u66f4\u6539\u7684\u96c6\u5408\u3002\u5217\u8868\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u5206\u914d\u4e00\u4e2a\u6570\u5b57 &#8211; \u5b83\u7684\u4f4d\u7f6e\uff0c\u6216\u7d22\u5f15\uff0c\u7b2c\u4e00\u4e2a\u7d22\u5f15\u662f0\uff0c\u7b2c\u4e8c\u4e2a\u7d22\u5f15\u662f1\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002Python\u67096\u4e2a\u5e8f\u5217\u7684\u5185\u7f6e\u7c7b\u578b\uff0c\u4f46\u6700\u5e38\u89c1\u7684\u662f\u5217\u8868\u548c\u5143\u7ec4\u3002\u5728Python\u4e2d\uff0c\u5217\u8868\u53ef\u4ee5\u4f7f\u7528\u65b9\u62ec\u53f7\uff08<a href=\"https:\/\/zhuanlan.zhihu.com\/p\/351605959\">]\uff09\u6765\u521b\u5efa\u3002Python\u4e2d\u7684\u5217\u8868\u53ef\u4ee5\u8fdb\u884c\u62fc\u63a5\u3001\u8bbf\u95ee\u3001\u5224\u65ad\u5b50\u4e32\u662f\u5426\u5728\u5df2\u77e5\u7684\u5217\u8868\u4e2d\u7b49\u64cd\u4f5c\u3002Python\u4e2d\u7684\u5217\u8868\u8fd8\u6709\u4e00\u4e9b\u5185\u7f6e\u51fd\u6570\uff0c\u5982len()\u3001append()\u3001pop()\u7b49\uff0c\u53ef\u4ee5\u5bf9\u5217\u8868\u8fdb\u884c\u64cd\u4f5c<\/a><a href=\"https:\/\/bing.com\/search?q=Python%E5%88%97%E8%A1%A8\">1<\/a><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/351605959\">2<\/a><a href=\"http:\/\/c.biancheng.net\/view\/4328.html\">3<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u4ee5\u4e0b\u662fPython\u4e2d\u5217\u8868\u7684\u793a\u4f8b\uff1a<br>\u200b<br># \u521b\u5efa\u4e00\u4e2a\u7a7a\u5217\u8868<br>myList = []<br>\u200b<br># \u5411\u5217\u8868\u6dfb\u52a0\u5143\u7d20<br>myList.append('apple')<br>myList.append('banana')<br>myList.append('orange')<br>\u200b<br># \u4ece\u5217\u8868\u4e2d\u5207\u7247\u5143\u7d20<br>print(myList[0]) # \u8f93\u51fa\u7b2c\u4e00\u4e2a\u5143\u7d20<br>print(myList[1:3]) # \u8f93\u51fa\u7b2c\u4e8c\u4e2a\u5230\u7b2c\u4e09\u4e2a\u5143\u7d20<br>\u200b<br># \u641c\u7d22\u5217\u8868\u5e76\u67e5\u627e\u5143\u7d20<br>print('apple' in myList) # \u8f93\u51faTrue<br>print('pear' in myList) # \u8f93\u51faFalse<br>\u200b<br># \u5220\u9664\u5217\u8868\u4e2d\u7684\u5143\u7d20<br>del myList[0] # \u5220\u9664\u7b2c\u4e00\u4e2a\u5143\u7d20<br>\u200b<br># \u5f39\u51fa\u5217\u8868\u4e2d\u7684\u5143\u7d20<br>myList.pop() # \u5f39\u51fa\u6700\u540e\u4e00\u4e2a\u5143\u7d20<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">python\u4e2d\u7684\u5143\u7ec4\u3001\u793a\u4f8b<\/h3>\n\n\n\n<p>\u5143\u7ec4\u662fPython\u4e2d\u7684\u4e00\u79cd\u5e8f\u5217\u7c7b\u578b\uff0c\u4e0e\u5217\u8868\u7c7b\u4f3c\uff0c\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u5143\u7ec4\u7684\u5143\u7d20\u4e0d\u80fd\u4fee\u6539\u3002\u5143\u7ec4\u4f7f\u7528\u5c0f\u62ec\u53f7\uff0c\u5217\u8868\u4f7f\u7528\u65b9\u62ec\u53f7\u3002\u5143\u7ec4\u521b\u5efa\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u62ec\u53f7\u4e2d\u6dfb\u52a0\u5143\u7d20\uff0c\u5e76\u4f7f\u7528\u9017\u53f7\u9694\u5f00\u5373\u53ef\u3002\u5982\u4e0b\u5b9e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tup1 = ('physics', 'chemistry', 1997, 2000)<br>tup2 = (1, 2, 3, 4, 5 )<br>tup3 = \"a\", \"b\", \"c\", \"d\"<\/pre>\n\n\n\n<p>\u521b\u5efa\u7a7a\u5143\u7ec4\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tup1 = ()<\/pre>\n\n\n\n<p>\u5143\u7ec4\u4e2d\u53ea\u5305\u542b\u4e00\u4e2a\u5143\u7d20\u65f6\uff0c\u9700\u8981\u5728\u5143\u7d20\u540e\u9762\u6dfb\u52a0\u9017\u53f7\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tup1 = (50,)<\/pre>\n\n\n\n<p>\u8bbf\u95ee\u5143\u7ec4\uff1a\u5143\u7ec4\u53ef\u4ee5\u4f7f\u7528\u4e0b\u6807\u7d22\u5f15\u6765\u8bbf\u95ee\u5143\u7ec4\u4e2d\u7684\u503c\uff0c\u5982\u4e0b\u5b9e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tup1 = ('physics', 'chemistry', 1997, 2000)<br>tup2 = (1, 2, 3, 4, 5, 6, 7 )<br> <br>print (\"tup1[0]: \", tup1[0])<br>print (\"tup2[1:5]: \", tup2[1:5])<\/pre>\n\n\n\n<p>\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">tup1[0]: physics<br>tup2[1:5]: (2, 3, 4, 5)<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u521b\u5efa\u4e00\u4e2a\u7a7a\u5143\u7ec4<br>myTuple = ()<br>\u200b<br># \u7528\u540c\u6784\u5143\u7d20\u521b\u5efa\u5143\u7ec4<br>myTuple = (1, 2, 3)<br>\u200b<br># \u521b\u5efa\u5177\u6709\u5f02\u6784\u5143\u7d20\u7684\u5143\u7ec4<br>myTuple = (1, \"Hello\", 3.4)<br>\u200b<br># \u7528\u5355\u4e2a\u5143\u7d20\u521b\u5efa\u5143\u7ec4<br>myTuple = (1,) # \u6ce8\u610f\u9017\u53f7<br>\u200b<br># \u4fee\u6539\u5143\u7ec4\u7684\u5143\u7d20<br>myTuple = (1, 2, 3)<br>myTuple[0] = 4 # TypeError: 'tuple' object does not support item assignment<br>\u200b<br># \u8bbf\u95ee\u5143\u7ec4\u7684\u5143\u7d20\u2014\u2014\u4ece\u524d\u9762<br>myTuple = (1, 2, 3)<br>print(myTuple[0]) # \u8f93\u51fa\u7b2c\u4e00\u4e2a\u5143\u7d20<br>\u200b<br># \u8bbf\u95ee\u5143\u7ec4\u7684\u5143\u7d20\u2014\u2014\u4ece\u540e\u9762<br>myTuple = (1, 2, 3)<br>print(myTuple[-1]) # \u8f93\u51fa\u6700\u540e\u4e00\u4e2a\u5143\u7d20<br>\u200b<br># \u5728\u5143\u7ec4\u4e2d\u641c\u7d22<br>myTuple = (1, 2, 3)<br>print(1 in myTuple) # \u8f93\u51faTrue<br>print(4 in myTuple) # \u8f93\u51faFalse<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">python \u4e2d\u7684\u5b57\u5178<\/h3>\n\n\n\n<p>\u5b57\u5178 (Dictionary)\u662fPython\u63d0\u4f9b\u7684\u4e00\u79cd\u5e38\u7528\u7684\u6570\u636e\u7ed3\u6784\uff0c\u7531\u952e\uff08key\uff09\u548c\u503c\uff08value\uff09\u6210\u5bf9\u7ec4\u6210\uff0c\u952e\u548c\u503c\u4e2d\u95f4\u4ee5\u5192\u53f7\uff1a\u9694\u5f00\uff0c\u9879\u4e4b\u95f4\u7528\u9017\u53f7\u9694\u5f00\uff0c\u6574\u4e2a\u5b57\u5178\u7531\u5927\u62ec\u53f7 {}\u62ec\u8d77\u6765\u3002\u5b57\u5178\u662f\u4e00\u79cd\u6620\u5c04\u7c7b\u578b\uff0c\u5b57\u5178\u7528 { } \u6807\u8bc6\uff0c\u5b83\u662f\u4e00\u4e2a\u65e0\u5e8f\u7684\u952e(key) : \u503c(value)\u5bf9\u96c6\u5408\u3002\u952e(key)\u5fc5\u987b\u4f7f\u7528\u4e0d\u53ef\u53d8\u7c7b\u578b\u3002\u5728\u540c\u4e00\u4e2a\u5b57\u5178\u4e2d\uff0c\u952e(key)\u5fc5\u987b\u662f\u552f\u4e00\u7684\u3002<\/p>\n\n\n\n<p>Python\u5b57\u5178\u7684\u57fa\u672c\u64cd\u4f5c\u5305\u62ec\u521b\u5efa\u3001\u8bbf\u95ee\u3001\u4fee\u6539\u548c\u5220\u9664\u7b49\u3002\u521b\u5efa\u5b57\u5178\u53ef\u4ee5\u4f7f\u7528\u82b1\u62ec\u53f7\u8bed\u6cd5\u6216\u8005dict()\u51fd\u6570\u3002\u5982\u4e0b\u5b9e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dict1 = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}<br>dict2 = {1: 'apple', 2: 'ball'}<\/pre>\n\n\n\n<p>\u8bbf\u95ee\u5b57\u5178\u4e2d\u7684\u503c\u53ef\u4ee5\u4f7f\u7528\u65b9\u62ec\u53f7 [] \u6765\u83b7\u53d6\u76f8\u5e94\u7684\u503c\uff0c\u5982\u4e0b\u5b9e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}<br> <br>print (\"dict['Name']: \", dict['Name'])<br>print (\"dict['Age']: \", dict['Age'])<\/pre>\n\n\n\n<p>\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">dict['Name']: Zara<br>dict['Age']: 7<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">python\u4e2d\u7684\u51fd\u6570<\/h3>\n\n\n\n<p>Python\u4e2d\u7684\u51fd\u6570\u662f\u7ec4\u7ec7\u597d\u7684\uff0c\u53ef\u91cd\u590d\u4f7f\u7528\u7684\uff0c\u7528\u6765\u5b9e\u73b0\u5355\u4e00\uff0c\u6216\u76f8\u5173\u8054\u529f\u80fd\u7684\u4ee3\u7801\u6bb5\u3002\u51fd\u6570\u80fd\u63d0\u9ad8\u5e94\u7528\u7684\u6a21\u5757\u6027\uff0c\u548c\u4ee3\u7801\u7684\u91cd\u590d\u5229\u7528\u7387\u3002\u5728Python\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u7684\u57fa\u672c\u8bed\u6cd5\u662f\u4f7f\u7528def\u5173\u952e\u5b57\uff0c\u540e\u9762\u662f\u62ec\u53f7\u548c\u5192\u53f7\u3002\u63a5\u4e0b\u6765\u4f60\u8981\u505a\u7684\u662f\u786e\u4fdd\u6309Tab\u952e\u62164\u4e2a\u7a7a\u683c\u7f29\u8fdb\uff0c\u7136\u540e\u6307\u5b9a\u4f60\u5e0c\u671b\u8fd9\u4e2a\u51fd\u6570\u4e3a\u4f60\u505a\u4ec0\u4e48\u3002\u4ee5\u4e0b\u662fPython\u4e2d\u51fd\u6570\u7684\u57fa\u672c\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">def functionName():<br> &nbsp; &nbsp;# \u8ba9\u51fd\u6570\u505a\u4ec0\u4e48<\/pre>\n\n\n\n<p>\u8981\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u8bf7\u5199\u51fa\u51fd\u6570\u7684\u540d\u79f0\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">functionName()<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">python\u4e2d\u7684\u6a21\u5757<\/h3>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/qq_38962621\/article\/details\/110448464\">Python\u4e2d\u7684\u6a21\u5757\u662f\u4e00\u4e2a\u5305\u542bPython\u5b9a\u4e49\u548c\u8bed\u53e5\u7684\u6587\u4ef6\uff0c\u4e5f\u5c31\u662f\u4e00\u4e2a.py\u6587\u4ef6\u5c31\u53ef\u4ee5\u79f0\u4e3a\u4e00\u4e2a\u6a21\u5757\u3002\u6a21\u5757\u53ef\u4ee5\u7528\u6765\u7ec4\u7ec7\u51fd\u6570\u3001\u7c7b\u7b49\u4ee3\u7801\uff0c\u7136\u540e\u5728\u5176\u4ed6\u7684\u7a0b\u5e8f\u4e2d\u5f15\u5165\u8fd9\u4e9b\u6a21\u5757\u4e2d\u7684\u529f\u80fd\uff0c\u6709\u5229\u4e8e\u4ee3\u7801\u7684\u7ba1\u7406\u4e0e\u63d0\u9ad8\u91cd\u7528\u6027<\/a><a href=\"https:\/\/bing.com\/search?q=Python%E4%B8%AD%E7%9A%84%E6%A8%A1%E5%9D%97\">1<\/a><a href=\"https:\/\/blog.csdn.net\/qq_38962621\/article\/details\/110448464\">2<\/a><a href=\"https:\/\/www.runoob.com\/python\/python-modules.html\">3<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">python\u4e2d\u7684\u7c7b\u4e0e\u5bf9\u8c61<\/h3>\n\n\n\n<p><a href=\"https:\/\/docs.python.org\/zh-cn\/3\/tutorial\/classes.html\">Python\u4e2d\u7684\u7c7b\u548c\u5bf9\u8c61\u662f\u9762\u5411\u5bf9\u8c61\u7f16\u7a0b\u7684\u57fa\u7840\u3002\u7c7b\u662f\u4e00\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5b83\u5b9a\u4e49\u4e86\u4e00\u7ec4\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u8fd9\u4e9b\u5c5e\u6027\u548c\u65b9\u6cd5\u53ef\u4ee5\u88ab\u5bf9\u8c61\u4f7f\u7528\u3002\u5bf9\u8c61\u662f\u7c7b\u7684\u5b9e\u4f8b\uff0c\u5b83\u53ef\u4ee5\u8bbf\u95ee\u7c7b\u4e2d\u5b9a\u4e49\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u5728Python\u4e2d\uff0c\u4f7f\u7528\u5173\u952e\u5b57class\u5b9a\u4e49\u4e00\u4e2a\u7c7b\uff0c\u7136\u540e\u5728\u7c7b\u4e2d\u5b9a\u4e49\u5c5e\u6027\u548c\u65b9\u6cd5<\/a><a href=\"https:\/\/bing.com\/search?q=Python%E4%B8%AD%E7%9A%84%E7%B1%BB%E4%B8%8E%E5%AF%B9%E8%B1%A1\">1<\/a><a href=\"https:\/\/docs.python.org\/zh-cn\/3\/tutorial\/classes.html\">2<\/a><a href=\"https:\/\/www.w3school.com.cn\/python\/python_classes.asp\">3<\/a>.<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684Python\u7c7b\u7684\u4f8b\u5b50\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a\u5c5e\u6027\u548c\u4e00\u4e2a\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">class MyClass:<br> &nbsp;  x = 5<br>\u200b<br> &nbsp;  def print_x(self):<br> &nbsp; &nbsp; &nbsp;  print(self.x)<br>\u200b<br>my_object = MyClass()<br>my_object.print_x()<\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u4f8b\u5b50\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3aMyClass\u7684\u7c7b\uff0c\u5b83\u6709\u4e00\u4e2a\u540d\u4e3ax\u7684\u5c5e\u6027\u548c\u4e00\u4e2a\u540d\u4e3aprint_x\u7684\u65b9\u6cd5\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3amy_object\u7684MyClass\u5bf9\u8c61\uff0c\u5e76\u8c03\u7528\u4e86\u5b83\u7684print_x\u65b9\u6cd5\uff0c\u8fd9\u5c06\u8f93\u51fa5\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">python\u6761\u4ef6\u8bed\u53e5\u548c\u5faa\u73af\u8bed\u53e5\u793a\u4f8b<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6761\u4ef6\u8bed\u53e5\uff1a\n<ul class=\"wp-block-list\">\n<li>if\u8bed\u53e5\uff1a\u8981\u5224\u65ad\u7684\u6761\u4ef6\u6210\u7acb\u65f6\u505a\u7684\u4e8b\u60c5\uff0c\u5426\u5219\u505a\u5176\u4ed6\u4e8b\u60c5\u3002\u793a\u4f8b\uff1aif x &gt; y:<br>print(&#8216;x is greater than y&#8217;)<br>else:<br>print(&#8216;y is greater than x&#8217;)`<\/li>\n\n\n\n<li>if-elif\u8bed\u53e5\uff1a\u8981\u5224\u65ad\u7684\u6761\u4ef6\u6210\u7acb\u65f6\u505a\u7684\u4e8b\u60c5\uff0c\u5426\u5219\u7ee7\u7eed\u5224\u65ad\u4e0b\u4e00\u4e2a\u6761\u4ef6\u3002\u793a\u4f8b\uff1aif x &gt; y:<br>print(&#8216;x is greater than y&#8217;)<br>elif x &lt; y:<br>&nbsp; &nbsp;print(&#8216;y is greater than x&#8217;)<br>&nbsp; &nbsp;else:<br>&nbsp; &nbsp; &nbsp; &nbsp;print(&#8216;x and y are equal&#8217;)`\u5faa\u73af\u8bed\u53e5\uff1a<\/li>\n\n\n\n<li>while\u5faa\u73af\uff1a\u5f53\u6761\u4ef6\u4e3a\u771f\u65f6\uff0c\u4e00\u76f4\u5faa\u73af\u4e0b\u53bb\u3002\u793a\u4f8b\uff1ax = 0while x &lt; 10: print(x) x += 1`<\/li>\n\n\n\n<li>for\u5faa\u73af\uff1a\u904d\u5386\u5e8f\u5217\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u5e76\u6267\u884c\u4ee3\u7801\u5757\u3002\u793a\u4f8b\uff1a <code>for i in range(0, 10):<\/code> print(i)`<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">python\u4e2d\u5982\u4f55\u8fdb\u884c\u6587\u4ef6\u6309\u64cd\u4f5c<\/h1>\n\n\n\n<p>Python\u4e2d\u8fdb\u884c\u6587\u4ef6\u64cd\u4f5c\u7684\u4e3b\u8981\u6a21\u5757\u662fos\u548cshutil\uff0c\u5176\u4e2dos\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u4e9b\u57fa\u672c\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570\uff0c\u5982\u6253\u5f00\u3001\u8bfb\u53d6\u3001\u5199\u5165\u3001\u5173\u95ed\u6587\u4ef6\u7b49\uff0c\u800cshutil\u6a21\u5757\u5219\u63d0\u4f9b\u4e86\u4e00\u4e9b\u9ad8\u7ea7\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570\uff0c\u5982\u590d\u5236\u3001\u79fb\u52a8\u3001\u91cd\u547d\u540d\u3001\u5220\u9664\u6587\u4ef6\u7b49\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6587\u4ef6\u64cd\u4f5c\u51fd\u6570\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6253\u5f00\u6587\u4ef6\uff1a\u4f7f\u7528open()\u51fd\u6570\u6253\u5f00\u4e00\u4e2a\u6587\u4ef6\uff0c\u53ef\u4ee5\u6307\u5b9a\u6253\u5f00\u65b9\u5f0f\uff08\u53ea\u8bfb\u3001\u53ea\u5199\u3001\u8ffd\u52a0\u7b49\uff09\u548c\u7f16\u7801\u65b9\u5f0f\u3002<\/li>\n\n\n\n<li>\u8bfb\u53d6\u6587\u4ef6\uff1a\u4f7f\u7528read()\u51fd\u6570\u8bfb\u53d6\u6587\u4ef6\u5185\u5bb9\uff0c\u53ef\u4ee5\u6307\u5b9a\u8bfb\u53d6\u7684\u5b57\u8282\u6570\u6216\u8bfb\u53d6\u5230\u67d0\u4e2a\u5b57\u7b26\u3002<\/li>\n\n\n\n<li>\u5199\u5165\u6587\u4ef6\uff1a\u4f7f\u7528write()\u51fd\u6570\u5411\u6587\u4ef6\u4e2d\u5199\u5165\u5185\u5bb9\uff0c\u53ef\u4ee5\u6307\u5b9a\u5199\u5165\u7684\u4f4d\u7f6e\u548c\u5199\u5165\u7684\u5185\u5bb9\u3002<\/li>\n\n\n\n<li>\u5173\u95ed\u6587\u4ef6\uff1a\u4f7f\u7528close()\u51fd\u6570\u5173\u95ed\u4e00\u4e2a\u5df2\u7ecf\u6253\u5f00\u7684\u6587\u4ef6\u3002<\/li>\n\n\n\n<li>\u590d\u5236\u6587\u4ef6\uff1a\u4f7f\u7528shutil.copy()\u51fd\u6570\u590d\u5236\u4e00\u4e2a\u6587\u4ef6\u5230\u53e6\u4e00\u4e2a\u4f4d\u7f6e\u3002<\/li>\n\n\n\n<li>\u79fb\u52a8\u6587\u4ef6\uff1a\u4f7f\u7528shutil.move()\u51fd\u6570\u79fb\u52a8\u4e00\u4e2a\u6587\u4ef6\u5230\u53e6\u4e00\u4e2a\u4f4d\u7f6e\u3002<\/li>\n\n\n\n<li>\u5220\u9664\u6587\u4ef6\uff1a\u4f7f\u7528os.remove()\u51fd\u6570\u5220\u9664\u4e00\u4e2a\u6587\u4ef6\u3002<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">Python\u4e2d\u5982\u4f55\u8fdb\u884c\u5f02\u5e38\u5904\u7406\uff1f<\/h1>\n\n\n\n<p>\u5728Python\u4e2d\uff0c\u5f02\u5e38\u5904\u7406\u7684\u57fa\u672c\u5f62\u5f0f\u662f\u4f7f\u7528<code>try...except<\/code>\u8bed\u53e5\u3002\u8fd9\u4e00\u70b9\u5176\u5b9e\u6bd4\u8f83\u7c7b\u4f3c\u4e8eJava\u4e2d\u7684<code>try...catch<\/code>\u8bed\u53e5\uff0c\u4e8b\u5b9e\u4e0a\uff0c\u5927\u90e8\u5206\u8bed\u8a00\u90fd\u6709\u7c7b\u4f3c\u7684\u6355\u6349\u5f02\u5e38\u7684\u65b9\u6cd5\u3002\u5904\u7406\u5f02\u5e38\u7684\u6807\u51c6\u65b9\u6cd5\u5c31\u662f\u4f7f\u7528<code>try...except<\/code>\u8bed\u53e5\u3002\u5982\u679c\u672a\u7ecf\u5904\u7406\u7684\u5f02\u5e38\u4f1a\u76f4\u63a5\u4e2d\u65adPython\u7a0b\u5e8f\u7684\u8fd0\u884c\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u6355\u83b7\u5f02\u5e38\u5e76\u5bf9\u5176\u8fdb\u884c\u5904\u7406\u3002\u6211\u4eec\u53ef\u4ee5\u5c06\u5f02\u5e38\u8d4b\u503c\u7ed9\u4e00\u4e2a\u53d8\u91cf\uff0c\u4ece\u800c\u8fdb\u4e00\u6b65\u4e86\u89e3\u8be5\u5f02\u5e38\u7684\u76f8\u5173\u4fe1\u606f\uff0c\u65b9\u4fbf\u5bf9\u8be5\u5f02\u5e38\u8fdb\u884c\u5904\u7406\u3002\u4f8b\u5982\uff0c\u5728\u4e0b\u9762\u4ee3\u7801\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u5904\u7406\u540e\u7684TypeError\u5f02\u5e38\u8d4b\u503c\u7ed9\u53d8\u91cfe\uff0c\u5e76\u5c06\u5176\u6253\u5370\u51fa\u6765\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">try:<br> &nbsp; &nbsp;# some code<br>except TypeError as e:<br> &nbsp; &nbsp;print(e)<\/pre>\n\n\n\n<p>\u5982\u679c\u4f60\u60f3\u629b\u51fa\u4e00\u4e2a\u5f02\u5e38\uff0c\u53ef\u4ee5\u4f7f\u7528<code>raise<\/code>\u8bed\u53e5\u3002\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">raise Exception(\"An error occurred\")<\/pre>\n\n\n\n<p>\u8fd9\u5c06\u629b\u51fa\u4e00\u4e2a\u5e26\u6709\u9519\u8bef\u6d88\u606f\u201cAn error occurred\u201d\u7684Exception\u5f02\u5e38\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5e38\u89c1\u9519\u8bef<\/h1>\n\n\n\n<p><a href=\"https:\/\/blog.csdn.net\/tsfy2003\/article\/details\/115727420\">Python\u4e2d\u5e38\u89c1\u7684\u9519\u8bef\u5305\u62ec\u8bed\u6cd5\u9519\u8bef\u548c\u5f02\u5e38\u3002\u8bed\u6cd5\u9519\u8bef\u662f\u521d\u5b66\u8005\u6700\u5bb9\u6613\u72af\u7684\u9519\u8bef\uff0c\u5982\u679c\u4ee3\u7801\u4e0d\u7b26\u5408Python\u7684\u8bed\u6cd5\u89c4\u8303\uff0c\u6bd4\u5982\u6f0f\u4e86\u5192\u53f7\uff0c\u6df7\u7528\u4e2d\u82f1\u6587\u7b26\u53f7\u7b49\uff0c\u5c31\u4f1a\u51fa\u73b0\u8fd9\u79cd\u9519\u8bef\u3002\u800c\u5f02\u5e38\u5219\u662f\u5728\u8fd0\u884cPython\u65f6\u7ecf\u5e38\u4f1a\u9047\u5230\u7684\u5404\u79cd\u5404\u6837\u7684\u9519\u8bef\u3002\u4ee5\u4e0b\u662fPython\u5e38\u89c1\u7684\u9519\u8bef\u4ee5\u53ca\u89e3\u51b3\u65b9\u6cd5<\/a><a href=\"https:\/\/blog.csdn.net\/tsfy2003\/article\/details\/115727420\">1<\/a><a href=\"https:\/\/www.runoob.com\/python\/python-exceptions.html\">2<\/a><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/88931808\">3<\/a><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/78622323\">4<\/a><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/150263797\">5<\/a>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SyntaxError\uff1a\u8bed\u6cd5\u9519\u8bef<\/li>\n\n\n\n<li>IndentationError\uff1a\u7f29\u8fdb\u9519\u8bef<\/li>\n\n\n\n<li>NameError\uff1a\u540d\u79f0\u9519\u8bef<\/li>\n\n\n\n<li>TypeError\uff1a\u7c7b\u578b\u9519\u8bef<\/li>\n\n\n\n<li>ValueError\uff1a\u6570\u503c\u9519\u8bef<\/li>\n\n\n\n<li>ZeroDivisionError\uff1a\u9664\u6570\u4e3a\u96f6<\/li>\n\n\n\n<li>IOError\uff1a\u8f93\u5165\u8f93\u51fa\u9519\u8bef<\/li>\n\n\n\n<li>ImportError\uff1a\u5bfc\u5165\u6a21\u5757\u6216\u8005\u5305\u9519\u8bef<\/li>\n\n\n\n<li>IndexError\uff1a\u4e0b\u6807\u8d8a\u754c<\/li>\n\n\n\n<li>KeyError\uff1a\u5b57\u5178\u5173\u952e\u5b57\u4e0d\u5b58\u5728<\/li>\n\n\n\n<li>AttributeError\uff1a\u8bbf\u95ee\u5bf9\u8c61\u5c5e\u6027\u4e0d\u5b58\u5728<\/li>\n\n\n\n<li>Exception\uff1a\u6240\u6709\u5f02\u5e38\u7684\u57fa\u7c7b<\/li>\n<\/ul>\n\n\n\n<p>\u5e0c\u671b\u8fd9\u80fd\u5e2e\u5230\u4f60\uff01<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">Python\u4e2d\u5982\u4f55\u8c03\u8bd5\u4ee3\u7801\uff1f<\/h1>\n\n\n\n<p><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/142642410\">Python\u4e2d\u6709\u5f88\u591a\u8c03\u8bd5\u5de5\u5177\uff0c\u5176\u4e2d\u6bd4\u8f83\u5e38\u7528\u7684\u6709pdb\u3001ipdb\u3001pudb\u3001PyCharm\u7b49\u3002\u8fd9\u91cc\u6211\u4ecb\u7ecd\u4e00\u4e0b\u4f7f\u7528VS Code\u8fdb\u884cPython\u4ee3\u7801\u8c03\u8bd5\u7684\u65b9\u6cd5<\/a><a href=\"https:\/\/bing.com\/search?q=Python%E8%B0%83%E8%AF%95%E4%BB%A3%E7%A0%81\">1<\/a><a href=\"https:\/\/zhuanlan.zhihu.com\/p\/142642410\">2<\/a>\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u5b89\u88c5VS Code\u548cPython\u6269\u5c55<\/li>\n\n\n\n<li>\u914d\u7f6e\u8c03\u8bd5\u73af\u5883<\/li>\n\n\n\n<li>\u7f16\u5199\u4e00\u6bb5\u8c03\u8bd5\u7528\u7684\u4ee3\u7801<\/li>\n\n\n\n<li>\u542f\u52a8\u8c03\u8bd5\u5668<\/li>\n<\/ol>\n\n\n\n<p>\u5177\u4f53\u6b65\u9aa4\u53ef\u4ee5\u53c2\u8003\u8fd9\u7bc7\u6587\u7ae0\uff1a<a href=\"https:\/\/zhuanlan.zhihu.com\/p\/142642410\">Python \u4f7f\u7528VS Code\u8fdb\u884c\u8c03\u8bd5<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>python\u6982\u8ff0python\u5173\u952e\u5b57python\u7684\u8bed\u6cd5\u7ed3\u6784\u548c\u5e94\u7528python\u5e38\u89c1\u8bed <span class=\"readmore\"><a href=\"http:\/\/g1n29wqq.ipyingshe.net:5347\/?p=3236\">Continue Reading<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,10],"tags":[],"class_list":["post-3236","post","type-post","status-publish","format-standard","hentry","category-2","category-python"],"_links":{"self":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3236","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3236"}],"version-history":[{"count":1,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3236\/revisions"}],"predecessor-version":[{"id":3237,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=\/wp\/v2\/posts\/3236\/revisions\/3237"}],"wp:attachment":[{"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3236"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/g1n29wqq.ipyingshe.net:5347\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}