{"id":551,"date":"2020-12-22T01:12:07","date_gmt":"2020-12-21T17:12:07","guid":{"rendered":"http:\/\/www.mimiq.com.cn\/?p=551"},"modified":"2020-12-22T01:14:08","modified_gmt":"2020-12-21T17:14:08","slug":"deepops%e7%9a%84python%e5%b0%8f%e7%ac%94%e8%ae%b0-%e5%a4%a9%e6%b1%a0%e9%be%99%e7%8f%a0%e8%ae%a1%e5%88%92-python%e8%ae%ad%e7%bb%83%e8%90%a5-task-01day3","status":"publish","type":"post","link":"http:\/\/www.mimiq.com.cn\/?p=551","title":{"rendered":"DeepOps\u7684Python\u5c0f\u7b14\u8bb0-\u5929\u6c60\u9f99\u73e0\u8ba1\u5212-Python\u8bad\u7ec3\u8425-Task 01:DAY3"},"content":{"rendered":"\n<p>\u4eca\u5929\u7684\u4efb\u52a1\u4e3b\u8981\u662f\u5f02\u5e38\u5904\u7406\uff0c\u6211\u76ee\u524d\u5199\u7684python \u8fd8\u6ca1\u7528\u8fc7\u5f02\u5e38\u5904\u7406\u3002\uff08\u6362\u53e5\u8bdd\u8fd8\u6ca1\u6709\u6b63\u7ecf\u5199\u8fc7\uff09<\/p>\n\n\n\n<h2>\u5f02\u5e38\u5904\u7406<\/h2>\n\n\n\n<h2>Python \u6807\u51c6\u5f02\u5e38\u603b\u7ed3<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>BaseException\uff1a\u6240\u6709\u5f02\u5e38\u7684 \u57fa\u7c7b\nException\uff1a\u5e38\u89c4\u5f02\u5e38\u7684 \u57fa\u7c7b\nStandardError\uff1a\u6240\u6709\u7684\u5185\u5efa\u6807\u51c6\u5f02\u5e38\u7684\u57fa\u7c7b\nArithmeticError\uff1a\u6240\u6709\u6570\u503c\u8ba1\u7b97\u5f02\u5e38\u7684\u57fa\u7c7b\nFloatingPointError\uff1a\u6d6e\u70b9\u8ba1\u7b97\u5f02\u5e38\nOverflowError\uff1a\u6570\u503c\u8fd0\u7b97\u8d85\u51fa\u6700\u5927\u9650\u5236\nZeroDivisionError\uff1a\u9664\u6570\u4e3a\u96f6\nAssertionError\uff1a\u65ad\u8a00\u8bed\u53e5\uff08assert\uff09\u5931\u8d25\nAttributeError\uff1a\u5c1d\u8bd5\u8bbf\u95ee\u672a\u77e5\u7684\u5bf9\u8c61\u5c5e\u6027\nEOFError\uff1a\u6ca1\u6709\u5185\u5efa\u8f93\u5165\uff0c\u5230\u8fbeEOF\u6807\u8bb0\nEnvironmentError\uff1a\u64cd\u4f5c\u7cfb\u7edf\u5f02\u5e38\u7684\u57fa\u7c7b\nIOError\uff1a\u8f93\u5165\/\u8f93\u51fa\u64cd\u4f5c\u5931\u8d25\nOSError\uff1a\u64cd\u4f5c\u7cfb\u7edf\u4ea7\u751f\u7684\u5f02\u5e38\uff08\u4f8b\u5982\u6253\u5f00\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u6587\u4ef6\uff09\nWindowsError\uff1a\u7cfb\u7edf\u8c03\u7528\u5931\u8d25\nImportError\uff1a\u5bfc\u5165\u6a21\u5757\u5931\u8d25\u7684\u65f6\u5019\nKeyboardInterrupt\uff1a\u7528\u6237\u4e2d\u65ad\u6267\u884c\nLookupError\uff1a\u65e0\u6548\u6570\u636e\u67e5\u8be2\u7684\u57fa\u7c7b\nIndexError\uff1a\u7d22\u5f15\u8d85\u51fa\u5e8f\u5217\u7684\u8303\u56f4\nKeyError\uff1a\u5b57\u5178\u4e2d\u67e5\u627e\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u5173\u952e\u5b57\nMemoryError\uff1a\u5185\u5b58\u6ea2\u51fa\uff08\u53ef\u901a\u8fc7\u5220\u9664\u5bf9\u8c61\u91ca\u653e\u5185\u5b58\uff09\nNameError\uff1a\u5c1d\u8bd5\u8bbf\u95ee\u4e00\u4e2a\u4e0d\u5b58\u5728\u7684\u53d8\u91cf\nUnboundLocalError\uff1a\u8bbf\u95ee\u672a\u521d\u59cb\u5316\u7684\u672c\u5730\u53d8\u91cf\nReferenceError\uff1a\u5f31\u5f15\u7528\u8bd5\u56fe\u8bbf\u95ee\u5df2\u7ecf\u5783\u573e\u56de\u6536\u4e86\u7684\u5bf9\u8c61\nRuntimeError\uff1a\u4e00\u822c\u7684\u8fd0\u884c\u65f6\u5f02\u5e38\nNotImplementedError\uff1a\u5c1a\u672a\u5b9e\u73b0\u7684\u65b9\u6cd5\nSyntaxError\uff1a\u8bed\u6cd5\u9519\u8bef\u5bfc\u81f4\u7684\u5f02\u5e38 \nIndentationError\uff1a\u7f29\u8fdb\u9519\u8bef\u5bfc\u81f4\u7684\u5f02\u5e38\nTabError\uff1aTab\u548c\u7a7a\u683c\u6df7\u7528\nSystemError\uff1a\u4e00\u822c\u7684\u89e3\u91ca\u5668\u7cfb\u7edf\u5f02\u5e38\nTypeError\uff1a\u4e0d\u540c\u7c7b\u578b\u95f4\u7684\u65e0\u6548\u64cd\u4f5c\nValueError\uff1a\u4f20\u5165\u65e0\u6548\u7684\u53c2\u6570\nUnicodeError\uff1aUnicode\u76f8\u5173\u7684\u5f02\u5e38\nUnicodeDecodeError\uff1aUnicode\u89e3\u7801\u65f6\u7684\u5f02\u5e38\nUnicodeEncodeError\uff1aUnicode\u7f16\u7801\u9519\u8bef\u5bfc\u81f4\u7684\u5f02\u5e38\nUnicodeTranslateError\uff1aUnicode\u8f6c\u6362\u9519\u8bef\u5bfc\u81f4\u7684\u5f02\u5e38<\/code><\/pre>\n\n\n\n<h2>Python \u6807\u51c6\u8b66\u544a\u603b\u7ed3<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>- Warning\uff1a\u8b66\u544a\u7684\u57fa\u7c7b\n- DeprecationWarning\uff1a\u5173\u4e8e\u88ab\u5f03\u7528\u7684\u7279\u5f81\u7684\u8b66\u544a\n- FutureWarning\uff1a\u5173\u4e8e\u6784\u9020\u5c06\u6765\u8bed\u4e49\u4f1a\u6709\u6539\u53d8\u7684\u8b66\u544a\n- UserWarning\uff1a\u7528\u6237\u4ee3\u7801\u751f\u6210\u7684\u8b66\u544a\n- PendingDeprecationWarning\uff1a\u5173\u4e8e\u7279\u6027\u5c06\u4f1a\u88ab\u5e9f\u5f03\u7684\u8b66\u544a\n- RuntimeWarning\uff1a\u53ef\u7591\u7684\u8fd0\u884c\u65f6\u884c\u4e3a(runtime behavior)\u7684\u8b66\u544a\n- SyntaxWarning\uff1a\u53ef\u7591\u8bed\u6cd5\u7684\u8b66\u544a\n- ImportWarning\uff1a\u7528\u4e8e\u5728\u5bfc\u5165\u6a21\u5757\u8fc7\u7a0b\u4e2d\u89e6\u53d1\u7684\u8b66\u544a\n- UnicodeWarning\uff1a\u4e0eUnicode\u76f8\u5173\u7684\u8b66\u544a\n- BytesWarning\uff1a\u4e0e\u5b57\u8282\u6216\u5b57\u8282\u7801\u76f8\u5173\u7684\u8b66\u544a\n- ResourceWarning\uff1a\u4e0e\u8d44\u6e90\u4f7f\u7528\u76f8\u5173\u7684\u8b66\u544a<\/code><\/pre>\n\n\n\n<h2>try &#8211; except \u8bed\u53e5:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>try:\n-     \u68c0\u6d4b\u8303\u56f4\n- except Exception&#91;as reason]:\n-     \u51fa\u73b0\u5f02\u5e38\u540e\u7684\u5904\u7406\u4ee3\u7801<\/code><\/pre>\n\n\n\n<h2>try &#8211; except &#8211; finally \u8bed\u53e5:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>def divide(x, y):\n    try:\n        result = x \/ y\n        print(\"result is\", result)     \n    except ZeroDivisionError:\n        print(\"division by zero!\")\n     finally:\n        print(\"executing finally clause\")<\/code><\/pre>\n\n\n\n<h2>try &#8211; except &#8211; else \u8bed\u53e5 :<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>try:\n\t \u68c0\u6d4b\u8303\u56f4\nexcept:\n\t\u51fa\u73b0\u5f02\u5e38\u540e\u7684\u5904\u7406\u4ee3\u7801\nelse:\n\t\u5982\u679c\u6ca1\u6709\u5f02\u5e38\u6267\u884c\u8fd9\u5757\u4ee3\u7801<\/code><\/pre>\n\n\n\n<h2>raise\u8bed\u53e5<\/h2>\n\n\n\n<ul><li>Python \u4f7f\u7528raise\u8bed\u53e5\u629b\u51fa\u4e00\u4e2a\u6307\u5b9a\u7684\u5f02\u5e38\u3002<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>try:\n    raise NameError('HiThere')\nexcept NameError:\n    print('An exception flew by!')\n    \n# An exception flew by!<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u7684\u4efb\u52a1\u4e3b\u8981\u662f\u5f02\u5e38\u5904\u7406\uff0c\u6211\u76ee\u524d\u5199\u7684python \u8fd8\u6ca1\u7528\u8fc7\u5f02\u5e38\u5904\u7406\u3002\uff08\u6362\u53e5\u8bdd\u8fd8\u6ca1\u6709\u6b63\u7ecf\u5199\u8fc7\uff09 \u5f02\u5e38\u5904\u7406 Python \u6807\u51c6\u5f02\u5e38\u603b\u7ed3 Python \u6807\u51c6\u8b66\u544a\u603b\u7ed3 try &#8211; except \u8bed\u53e5: try &#8211; except &#8211; finally \u8bed\u53e5: try &#8211; except &#8211; else \u8bed\u53e5 : raise\u8bed\u53e5 Python \u4f7f\u7528raise\u8bed\u53e5\u629b\u51fa\u4e00\u4e2a\u6307\u5b9a\u7684\u5f02\u5e38\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[25],"tags":[],"_links":{"self":[{"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/551"}],"collection":[{"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=551"}],"version-history":[{"count":1,"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/551\/revisions"}],"predecessor-version":[{"id":552,"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=\/wp\/v2\/posts\/551\/revisions\/552"}],"wp:attachment":[{"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=551"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mimiq.com.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}