{"id":944,"date":"2017-10-17T11:03:29","date_gmt":"2017-10-17T03:03:29","guid":{"rendered":"http:\/\/192.168.1.20\/?p=944"},"modified":"2017-10-23T11:51:45","modified_gmt":"2017-10-23T03:51:45","slug":"{d4daabd1ba368d9860c36387ddb72bbda14f8f9559d69d60a952800885260c03}e3{d4daabd1ba368d9860c36387ddb72bbda14f8f9559d69d60a952800885260c03}80{47dd41ec6bdcbd9a214c783a3735392b82ea6d1d918378c5a53e0640702d813","status":"publish","type":"post","link":"http:\/\/alextop.top\/?p=944","title":{"rendered":"\u3010Python3\u4e4b\u5f02\u5e38\u5904\u7406\u3011"},"content":{"rendered":"<p style=\"background: #fefef2\"><span style=\"color:black; font-size:21pt\"><strong><span style=\"font-family:\u5b8b\u4f53\">\u4e00\u3001\u9519\u8bef\u548c\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:16pt\"><strong><span style=\"font-family:Verdana\">1.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u9519\u8bef<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u4ee3\u7801\u8fd0\u884c\u524d\u7684\u8bed\u6cd5\u6216\u8005\u903b\u8f91\u9519\u8bef<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8bed\u6cd5\u9519\u8bef\uff08\u8fd9\u79cd\u9519\u8bef\uff0c\u6839\u672c\u8fc7\u4e0d\u4e86<\/span><span style=\"font-family:Verdana\">python<\/span><span style=\"font-family:\u5b8b\u4f53\">\u89e3\u91ca\u5668\u7684\u8bed\u6cd5\u68c0\u6d4b\uff0c\u5fc5\u987b\u5728\u7a0b\u5e8f\u6267\u884c\u524d\u5c31\u6539\u6b63\uff09<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    def test:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">            ^<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">SyntaxError: invalid syntax<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python31.gif\" alt=\"\"\/><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\">\u00a0<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5176\u4ed6\u8bed\u6cd5\u9519\u8bef<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u903b\u8f91\u9519\u8bef<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">#\u7528\u6237\u8f93\u5165\u4e0d\u5b8c\u6574(\u6bd4\u5982\u8f93\u5165\u4e3a\u7a7a)\u6216\u8005\u8f93\u5165\u975e\u6cd5(\u8f93\u5165\u4e0d\u662f\u6570\u5b57\uff09<\/p>\n<p>num=input(&#8220;&gt;&gt;: &#8220;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">int(num)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">&gt;&gt;: fsf<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">Traceback (most recent call last):<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">  File &#8220;\/Users\/hexin\/PycharmProjects\/py3\/day9\/1.py&#8221;, line 4, in &lt;module&gt;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    int(num)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">ValueError: invalid literal for int() with base 10: &#8216;fsf&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:16pt\"><strong><span style=\"font-family:Verdana\">2.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f02\u5e38\u5b9a\u4e49<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u7a0b\u5e8f\u6267\u884c\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u95ee\u9898\u5bfc\u81f4\u7a0b\u5e8f\u65e0\u6cd5\u6267\u884c<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u5f02\u5e38\u7684\u5206\u7c7b\uff1a<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u7a0b\u5e8f\u9047\u5230\u903b\u8f91\u6216\u7b97\u6cd5\u9519\u8bef<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u8ba1\u7b97\u673a\u9519\u8bef\uff1a\u5185\u5b58\u4e0d\u591f\u6216\u8005<\/span><span style=\"font-family:Verdana\">io<\/span><span style=\"font-family:\u5b8b\u4f53\">\u9519\u8bef<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u5f02\u5e38\u7684\u6b65\u9aa4\uff1a<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<ol>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u5f02\u5e38\u4ea7\u751f\uff0c\u68c0\u67e5\u5230\u9519\u8bef\u4e14\u89e3\u91ca\u5668\u8ba4\u4e3a\u662f\u5f02\u5e38\uff0c\u629b\u51fa\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u5f02\u5e38\u5904\u7406\uff0c\u5f02\u5e38\u5904\u7406\uff0c\u622a\u83b7\u5f02\u5e38\uff0c\u7cfb\u7edf\u5ffd\u7565\u6216\u8005\u7ec8\u6b62\u7a0b\u5e8f\u5904\u7406\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python32.jpg\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python33.jpg\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t\t\t<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:16pt\"><strong><span style=\"font-family:Verdana\">3.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5e38\u89c1\u7684\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python34.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">AttributeError \u8bd5\u56fe\u8bbf\u95ee\u4e00\u4e2a\u5bf9\u8c61\u6ca1\u6709\u7684\u5c5e\u6027\uff0c\u6bd4\u5982foo.x\uff0c\u4f46\u662ffoo\u6ca1\u6709\u5c5e\u6027x<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>IOError \u8f93\u5165\/\u8f93\u51fa\u5f02\u5e38\uff1b\u57fa\u672c\u4e0a\u662f\u65e0\u6cd5\u6253\u5f00\u6587\u4ef6<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>ImportError \u65e0\u6cd5\u5f15\u5165\u6a21\u5757\u6216\u5305\uff1b\u57fa\u672c\u4e0a\u662f\u8def\u5f84\u95ee\u9898\u6216\u540d\u79f0\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>IndentationError \u8bed\u6cd5\u9519\u8bef\uff08\u7684\u5b50\u7c7b\uff09 \uff1b\u4ee3\u7801\u6ca1\u6709\u6b63\u786e\u5bf9\u9f50<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>IndexError \u4e0b\u6807\u7d22\u5f15\u8d85\u51fa\u5e8f\u5217\u8fb9\u754c\uff0c\u6bd4\u5982\u5f53x\u53ea\u6709\u4e09\u4e2a\u5143\u7d20\uff0c\u5374\u8bd5\u56fe\u8bbf\u95eex[5]<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>KeyError \u8bd5\u56fe\u8bbf\u95ee\u5b57\u5178\u91cc\u4e0d\u5b58\u5728\u7684\u952e<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>KeyboardInterrupt Ctrl+C\u88ab\u6309\u4e0b<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>NameError \u5c1d\u8bd5\u8bbf\u95ee\u4e00\u4e2a\u6ca1\u6709\u7533\u660e\u7684\u53d8\u91cf<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>SyntaxError Python\u4ee3\u7801\u975e\u6cd5\uff0c\u4ee3\u7801\u4e0d\u80fd\u7f16\u8bd1(\u4e2a\u4eba\u8ba4\u4e3a\u8fd9\u662f\u8bed\u6cd5\u9519\u8bef\uff0c\u5199\u9519\u4e86\uff09<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>TypeError \u4f20\u5165\u5bf9\u8c61\u7c7b\u578b\u4e0e\u8981\u6c42\u7684\u4e0d\u7b26\u5408<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>UnboundLocalError \u8bd5\u56fe\u8bbf\u95ee\u4e00\u4e2a\u8fd8\u672a\u88ab\u8bbe\u7f6e\u7684\u5c40\u90e8\u53d8\u91cf\uff0c\u57fa\u672c\u4e0a\u662f\u7531\u4e8e\u53e6\u6709\u4e00\u4e2a\u540c\u540d\u7684\u5168\u5c40\u53d8\u91cf\uff0c\u5bfc\u81f4\u4f60\u4ee5\u4e3a\u6b63\u5728\u8bbf\u95ee\u5b83<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"><br \/>ValueError \u4f20\u5165\u4e00\u4e2a\u8c03\u7528\u8005\u4e0d\u671f\u671b\u7684\u503c\uff0c\u5373\u4f7f\u503c\u7684\u7c7b\u578b\u662f\u6b63\u786e\u7684<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python35.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t\t\t<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8865\u5145\uff1a<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python36.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">\u5f02\u5e38\u540d\u79f0    \u63cf\u8ff0<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">BaseException    \u6240\u6709\u5f02\u5e38\u7684\u57fa\u7c7b<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">SystemExit    \u89e3\u91ca\u5668\u8bf7\u6c42\u9000\u51fa<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">KeyboardInterrupt    \u7528\u6237\u4e2d\u65ad\u6267\u884c(\u901a\u5e38\u662f\u8f93\u5165^C)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">Exception    \u5e38\u89c4\u9519\u8bef\u7684\u57fa\u7c7b<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">StopIteration    \u8fed\u4ee3\u5668\u6ca1\u6709\u66f4\u591a\u7684\u503c<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">GeneratorExit    \u751f\u6210\u5668(generator)\u53d1\u751f\u5f02\u5e38\u6765\u901a\u77e5\u9000\u51fa<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">StandardError    \u6240\u6709\u7684\u5185\u5efa\u6807\u51c6\u5f02\u5e38\u7684\u57fa\u7c7b<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">ArithmeticError    \u6240\u6709\u6570\u503c\u8ba1\u7b97\u9519\u8bef\u7684\u57fa\u7c7b<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">FloatingPointError    \u6d6e\u70b9\u8ba1\u7b97\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">OverflowError    \u6570\u503c\u8fd0\u7b97\u8d85\u51fa\u6700\u5927\u9650\u5236<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">ZeroDivisionError    \u9664(\u6216\u53d6\u6a21)\u96f6 (\u6240\u6709\u6570\u636e\u7c7b\u578b)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">AssertionError    \u65ad\u8a00\u8bed\u53e5\u5931\u8d25<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">AttributeError    \u5bf9\u8c61\u6ca1\u6709\u8fd9\u4e2a\u5c5e\u6027<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">EOFError    \u6ca1\u6709\u5185\u5efa\u8f93\u5165,\u5230\u8fbeEOF \u6807\u8bb0<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">EnvironmentError    \u64cd\u4f5c\u7cfb\u7edf\u9519\u8bef\u7684\u57fa\u7c7b<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">IOError    \u8f93\u5165\/\u8f93\u51fa\u64cd\u4f5c\u5931\u8d25<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">OSError    \u64cd\u4f5c\u7cfb\u7edf\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">WindowsError    \u7cfb\u7edf\u8c03\u7528\u5931\u8d25<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">ImportError    \u5bfc\u5165\u6a21\u5757\/\u5bf9\u8c61\u5931\u8d25<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">LookupError    \u65e0\u6548\u6570\u636e\u67e5\u8be2\u7684\u57fa\u7c7b<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">IndexError    \u5e8f\u5217\u4e2d\u6ca1\u6709\u6b64\u7d22\u5f15(index)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">KeyError    \u6620\u5c04\u4e2d\u6ca1\u6709\u8fd9\u4e2a\u952e<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">MemoryError    \u5185\u5b58\u6ea2\u51fa\u9519\u8bef(\u5bf9\u4e8ePython \u89e3\u91ca\u5668\u4e0d\u662f\u81f4\u547d\u7684)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">NameError    \u672a\u58f0\u660e\/\u521d\u59cb\u5316\u5bf9\u8c61 (\u6ca1\u6709\u5c5e\u6027)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">UnboundLocalError    \u8bbf\u95ee\u672a\u521d\u59cb\u5316\u7684\u672c\u5730\u53d8\u91cf<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">ReferenceError    \u5f31\u5f15\u7528(Weak reference)\u8bd5\u56fe\u8bbf\u95ee\u5df2\u7ecf\u5783\u573e\u56de\u6536\u4e86\u7684\u5bf9\u8c61<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">RuntimeError    \u4e00\u822c\u7684\u8fd0\u884c\u65f6\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">NotImplementedError    \u5c1a\u672a\u5b9e\u73b0\u7684\u65b9\u6cd5<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">SyntaxError    Python \u8bed\u6cd5\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">IndentationError    \u7f29\u8fdb\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">TabError    Tab \u548c\u7a7a\u683c\u6df7\u7528<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">SystemError    \u4e00\u822c\u7684\u89e3\u91ca\u5668\u7cfb\u7edf\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">TypeError    \u5bf9\u7c7b\u578b\u65e0\u6548\u7684\u64cd\u4f5c<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">ValueError    \u4f20\u5165\u65e0\u6548\u7684\u53c2\u6570<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">UnicodeError    Unicode \u76f8\u5173\u7684\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">UnicodeDecodeError    Unicode \u89e3\u7801\u65f6\u7684\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">UnicodeEncodeError    Unicode \u7f16\u7801\u65f6\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">UnicodeTranslateError    Unicode \u8f6c\u6362\u65f6\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">Warning    \u8b66\u544a\u7684\u57fa\u7c7b<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">DeprecationWarning    \u5173\u4e8e\u88ab\u5f03\u7528\u7684\u7279\u5f81\u7684\u8b66\u544a<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">FutureWarning    \u5173\u4e8e\u6784\u9020\u5c06\u6765\u8bed\u4e49\u4f1a\u6709\u6539\u53d8\u7684\u8b66\u544a<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">OverflowWarning    \u65e7\u7684\u5173\u4e8e\u81ea\u52a8\u63d0\u5347\u4e3a\u957f\u6574\u578b(long)\u7684\u8b66\u544a<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">PendingDeprecationWarning    \u5173\u4e8e\u7279\u6027\u5c06\u4f1a\u88ab\u5e9f\u5f03\u7684\u8b66\u544a<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">RuntimeWarning    \u53ef\u7591\u7684\u8fd0\u884c\u65f6\u884c\u4e3a(runtime behavior)\u7684\u8b66\u544a<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">SyntaxWarning    \u53ef\u7591\u7684\u8bed\u6cd5\u7684\u8b66\u544a<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">UserWarning    \u7528\u6237\u4ee3\u7801\u751f\u6210\u7684\u8b66\u544a<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python37.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t\t\t<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:21pt\"><strong><span style=\"font-family:\u5b8b\u4f53\">\u4e8c\u3001\u5f02\u5e38\u5904\u7406<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:16pt\"><strong><span style=\"font-family:Verdana\">1.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f02\u5e38\u5904\u7406\u7684\u5b9a\u4e49<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\">python<\/span><span style=\"font-family:\u5b8b\u4f53\">\u89e3\u91ca\u5668\u68c0\u6d4b\u5230\u9519\u8bef\uff0c\u89e6\u53d1\u5f02\u5e38\uff08\u4e5f\u5141\u8bb8\u7a0b\u5e8f\u5458\u81ea\u5df1\u89e6\u53d1\u5f02\u5e38\uff09<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u7a0b\u5e8f\u5458\u7f16\u5199\u7279\u5b9a\u7684\u4ee3\u7801\uff0c\u4e13\u95e8\u7528\u6765\u6355\u6349\u8fd9\u4e2a\u5f02\u5e38\uff08\u8fd9\u6bb5\u4ee3\u7801\u4e0e\u7a0b\u5e8f\u903b\u8f91\u65e0\u5173\uff0c\u4e0e\u5f02\u5e38\u5904\u7406\u6709\u5173\uff09<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u5982\u679c\u6355\u6349\u6210\u529f\u5219\u8fdb\u5165\u53e6\u5916\u4e00\u4e2a\u5904\u7406\u5206\u652f\uff0c\u6267\u884c\u4f60\u4e3a\u5176\u5b9a\u5236\u7684\u903b\u8f91\uff0c\u4f7f\u7a0b\u5e8f\u4e0d\u4f1a\u5d29\u6e83\uff0c\u8fd9\u5c31\u662f\u5f02\u5e38\u5904\u7406<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:16pt\"><strong><span style=\"font-family:Verdana\">2.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5f02\u5e38\u5904\u7406\u7684\u610f\u4e49<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t\t<\/span><\/strong><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\">python<\/span><span style=\"font-family:\u5b8b\u4f53\">\u89e3\u6790\u5668\u53bb\u6267\u884c\u7a0b\u5e8f\uff0c\u68c0\u6d4b\u5230\u4e86\u4e00\u4e2a\u9519\u8bef\u65f6\uff0c\u89e6\u53d1\u5f02\u5e38\uff0c\u5f02\u5e38\u89e6\u53d1\u540e\u4e14\u6ca1\u88ab\u5904\u7406\u7684\u60c5\u51b5\u4e0b\uff0c\u7a0b\u5e8f\u5c31\u5728\u5f53\u524d\u5f02\u5e38\u5904\u7ec8\u6b62\uff0c\u540e\u9762\u7684\u4ee3\u7801\u4e0d\u4f1a\u8fd0\u884c\uff0c\u6240\u4ee5\u4f60\u5fc5\u987b\u63d0\u4f9b\u4e00\u79cd\u5f02\u5e38\u5904\u7406\u673a\u5236\u6765\u589e\u5f3a\u4f60\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u4e0e\u5bb9\u9519\u6027<\/span><span style=\"font-family:Verdana\"><em>\u00a0<\/em><br \/>\n\t\t\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:16pt\"><strong><span style=\"font-family:Verdana\">3.<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5982\u4f55\u8fdb\u884c\u5f02\u5e38\u5904\u7406<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t\t<\/span><\/strong><\/span><\/p>\n<\/li>\n<\/ol>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u4f7f\u7528<\/span><span style=\"font-family:Verdana\">if<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5224\u65ad\u5f0f<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python38.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">num1=input(&#8216;&gt;&gt;: &#8216;) #\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\u8bd5\u8bd5<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">if num1.isdigit():<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    int(num1) #\u6211\u4eec\u7684\u6b63\u7edf\u7a0b\u5e8f\u653e\u5230\u4e86\u8fd9\u91cc,\u5176\u4f59\u7684\u90fd\u5c5e\u4e8e\u5f02\u5e38\u5904\u7406\u8303\u7574<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">elif num1.isspace():<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(&#8216;\u8f93\u5165\u7684\u662f\u7a7a\u683c,\u5c31\u6267\u884c\u6211\u8fd9\u91cc\u7684\u903b\u8f91&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">elif len(num1) == 0:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(&#8216;\u8f93\u5165\u7684\u662f\u7a7a,\u5c31\u6267\u884c\u6211\u8fd9\u91cc\u7684\u903b\u8f91&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">else:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(&#8216;\u5176\u4ed6\u60c5\u60c5\u51b5,\u6267\u884c\u6211\u8fd9\u91cc\u7684\u903b\u8f91&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">#\u7b2c\u4e8c\u6bb5\u4ee3\u7801<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"># num2=input(&#8216;&gt;&gt;: &#8216;) #\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\u8bd5\u8bd5<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"># int(num2)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">#\u7b2c\u4e09\u6bb5\u4ee3\u7801<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"># num3=input(&#8216;&gt;&gt;: &#8216;) #\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\u8bd5\u8bd5<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"># int(num3)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python39.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\"><br \/><\/span><span style=\"font-family:\u5b8b\u4f53\">\u95ee\u9898\u4e00\uff1a<\/span><span style=\"font-family:Verdana\"><br \/><\/span><span style=\"font-family:\u5b8b\u4f53\">\u4f7f\u7528<\/span><span style=\"font-family:Verdana\">if<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7684\u65b9\u5f0f\u6211\u4eec\u53ea\u4e3a\u7b2c\u4e00\u6bb5\u4ee3\u7801\u52a0\u4e0a\u4e86\u5f02\u5e38\u5904\u7406\uff0c\u9488\u5bf9\u7b2c\u4e8c\u6bb5\u4ee3\u7801\uff0c\u4f60\u5f97\u91cd\u65b0\u5199\u4e00\u5806<\/span><span style=\"font-family:Verdana\">if<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c<\/span><span style=\"font-family:Verdana\">elif<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7b49<\/span><span style=\"font-family:Verdana\"><br \/><\/span><span style=\"font-family:\u5b8b\u4f53\">\u800c\u8fd9\u4e9b<\/span><span style=\"font-family:Verdana\">if<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u8ddf\u4f60\u7684\u4ee3\u7801\u903b\u8f91\u5e76\u65e0\u5173\u7cfb<\/span><span style=\"font-family:Verdana\">,<\/span><span style=\"font-family:\u5b8b\u4f53\">\u53ef\u8bfb\u6027\u5dee<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u95ee\u9898\u4e8c\uff1a<\/span><span style=\"font-family:Verdana\"><br \/><\/span><span style=\"font-family:\u5b8b\u4f53\">\u7b2c\u4e00\u6bb5\u4ee3\u7801\u548c\u7b2c\u4e8c\u6bb5\u4ee3\u7801\u5b9e\u9645\u4e0a\u662f\u540c\u4e00\u79cd\u5f02\u5e38\uff0c\u90fd\u662f<\/span><span style=\"font-family:Verdana\">ValueError,<\/span><span style=\"font-family:\u5b8b\u4f53\">\u76f8\u540c\u7684\u9519\u8bef\u6309\u7406\u8bf4\u53ea\u5904\u7406\u4e00\u6b21\u5c31\u53ef\u4ee5\u4e86\uff0c\u800c\u7528<\/span><span style=\"font-family:Verdana\">if<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u7531\u4e8e\u8fd9\u4e8c\u8005<\/span><span style=\"font-family:Verdana\">if<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7684\u6761\u4ef6\u4e0d\u540c\uff0c\u8fd9\u53ea\u80fd\u903c\u7740\u4f60\u91cd\u65b0\u5199\u4e00\u4e2a\u65b0\u7684<\/span><span style=\"font-family:Verdana\">if<\/span><span style=\"font-family:\u5b8b\u4f53\">\u6765\u5904\u7406\u7b2c\u4e8c\u6bb5\u4ee3\u7801\u7684\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/><\/span><span style=\"font-family:\u5b8b\u4f53\">\u7b2c\u4e09\u6bb5\u4e5f\u4e00\u6837<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-family:Verdana; font-size:10pt\">try&#8230;except<br \/>\n<\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8bed\u6cd5\uff1a<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python310.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">&lt;\u8bed\u53e5&gt;        #\u8fd0\u884c\u522b\u7684\u4ee3\u7801<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except &lt;\u5f02\u5e38\u7c7b\u578b&gt;\uff1a<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">&lt;\u8bed\u53e5&gt;        #\u5982\u679c\u5728try\u90e8\u4efd\u5f15\u53d1\u4e86&#8217;name&#8217;\u5f02\u5e38<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except &lt;\u5f02\u5e38\u7c7b\u578b&gt; as &lt;\u6570\u636e&gt;:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">&lt;\u8bed\u53e5&gt;        #\u5982\u679c\u5f15\u53d1\u4e86&#8217;name&#8217;\u5f02\u5e38\uff0c\u83b7\u5f97\u9644\u52a0\u7684\u6570\u636e<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">else:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">&lt;\u8bed\u53e5&gt;        #\u5982\u679c\u6ca1\u6709\u5f02\u5e38\u53d1\u751f<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python311.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u6ce8\uff1a<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\">python2\u00a0<\/span><span style=\"font-family:\u5b8b\u4f53\">\u548c<\/span><span style=\"font-family:Verdana\"> 3\u00a0<\/span><span style=\"font-family:\u5b8b\u4f53\">\u5904\u7406<\/span><span style=\"font-family:Verdana\">\u00a0except <\/span><span style=\"font-family:\u5b8b\u4f53\">\u5b50\u53e5\u7684\u8bed\u6cd5\u6709\u70b9\u4e0d\u540c\uff0c\u9700\u8981\u6ce8\u610f\uff1b<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000<\/span><span style=\"font-family:Verdana\">Python2\u00a0\u00a0\u00a0<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print (1\/0)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except ZeroDivisionError, err:\u3000\u3000\u3000\u3000\u3000\u3000# , \u52a0\u539f\u56e0\u53c2\u6570\u540d\u79f0<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print (&#8216;Exception: &#8216;, err)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u3000\u3000\u3000\u3000\u3000\u3000\u3000\u3000<\/span><span style=\"font-family:Verdana\">Python3\u00a0\u00a0\u00a0<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print (1\/0)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except ZeroDivisionError as err:        # as \u52a0\u539f\u56e0\u53c2\u6570\u540d\u79f0<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print (&#8216;Exception: &#8216;, err)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u4f8b<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python312.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    fh = open(&#8220;testfile&#8221;, &#8220;w&#8221;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    fh.write(&#8220;\u8fd9\u662f\u4e00\u4e2a\u6d4b\u8bd5\u6587\u4ef6\uff0c\u7528\u4e8e\u6d4b\u8bd5\u5f02\u5e38!!&#8221;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except IOError:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(&#8220;Error: \u6ca1\u6709\u627e\u5230\u6587\u4ef6\u6216\u8bfb\u53d6\u6587\u4ef6\u5931\u8d25&#8221;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">else:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(&#8220;\u5185\u5bb9\u5199\u5165\u6587\u4ef6\u6210\u529f&#8221;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    fh.close()<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python313.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">\u5185\u5bb9\u5199\u5165\u6587\u4ef6\u6210\u529f<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u6ce8\uff1a<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u5f02\u5e38\u7c7b\u53ea\u80fd\u7528\u6765\u5904\u7406\u6307\u5b9a\u7684\u5f02\u5e38\u60c5\u51b5\uff0c\u5982\u679c\u975e\u6307\u5b9a\u5f02\u5e38\u5219\u65e0\u6cd5\u5904\u7406\u3002\uff08<strong>\u5f02\u5e38\u662f\u7531\u7a0b\u5e8f\u7684\u9519\u8bef\u5f15\u8d77\u7684\uff0c\u8bed\u6cd5\u4e0a\u7684\u9519\u8bef\u8ddf\u5f02\u5e38\u5904\u7406\u65e0\u5173\uff0c\u5fc5\u987b\u5728\u7a0b\u5e8f\u8fd0\u884c\u524d\u5c31\u4fee\u6b63\uff09<\/strong><\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python314.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\"># \u672a\u6355\u83b7\u5230\u5f02\u5e38\uff0c\u7a0b\u5e8f\u76f4\u63a5\u62a5\u9519<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">s1 = &#8216;hello&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    int(s1)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except IndexError as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print e<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python315.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">  File &#8220;\/Users\/hexin\/PycharmProjects\/py3\/day9\/1.py&#8221;, line 11<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print e<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">          ^<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">SyntaxError: Missing parentheses in call to &#8216;print&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u591a\u5206\u652f<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python316.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    msg=input(&#8216;&gt;&gt;:&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    int(msg) #ValueError<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    #<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    # print(x) #NameError<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    # #<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    # # l=[1,2]<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    # # l[10] #IndexError<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    #<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    # 1+&#8217;asdfsadfasdf&#8217; #TypeError<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except ValueError as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except NameError:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(&#8216;NameError&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except KeyError as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python317.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">&gt;&gt;:gg<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">invalid literal for int() with base 10: &#8216;gg&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u4e07\u80fd\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u5728<\/span><span style=\"font-family:Verdana\">python<\/span><span style=\"font-family:\u5b8b\u4f53\">\u7684\u5f02\u5e38\u4e2d\uff0c\u6709\u4e00\u4e2a\u4e07\u80fd\u5f02\u5e38\uff1a<\/span><span style=\"font-family:Verdana\">Exception<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff0c\u4ed6\u53ef\u4ee5\u6355\u83b7\u4efb\u610f\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">s1 = &#8216;hello&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    int(s1)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except Exception as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    &#8216;\u4e22\u5f03\u6216\u8005\u6267\u884c\u5176\u4ed6\u903b\u8f91&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">invalid literal for int() with base 10: &#8216;hello&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\">try-finally <\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bed\u53e5<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\">try-finally <\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bed\u53e5\u65e0\u8bba\u662f\u5426\u53d1\u751f\u5f02\u5e38\u90fd\u5c06\u6267\u884c\u6700\u540e\u7684\u4ee3\u7801\u3002<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python318.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">s1 = &#8216;hello&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    int(s1)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except IndexError as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except KeyError as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except ValueError as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">#except Exception as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">#    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">else:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(&#8216;try\u5185\u4ee3\u7801\u5757\u6ca1\u6709\u5f02\u5e38\u5219\u6267\u884c\u6211&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">finally:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(&#8216;\u65e0\u8bba\u5f02\u5e38\u4e0e\u5426,\u90fd\u4f1a\u6267\u884c\u8be5\u6a21\u5757,\u901a\u5e38\u662f\u8fdb\u884c\u6e05\u7406\u5de5\u4f5c&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python319.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">invalid literal for int() with base 10: &#8216;hello&#8217;<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">\u65e0\u8bba\u5f02\u5e38\u4e0e\u5426,\u90fd\u4f1a\u6267\u884c\u8be5\u6a21\u5757,\u901a\u5e38\u662f\u8fdb\u884c\u6e05\u7406\u5de5\u4f5c<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\">raise<\/span><span style=\"font-family:\u5b8b\u4f53\">\u4e3b\u52a8\u89e6\u53d1\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<\/span><span style=\"font-family:Verdana\">raise<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bed\u53e5\u81ea\u5df1\u89e6\u53d1\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:Verdana\">raise<\/span><span style=\"font-family:\u5b8b\u4f53\">\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\uff1a<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">raise [Exception [, args [, traceback]]]<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8bed\u53e5\u4e2d<\/span><span style=\"font-family:Verdana\">Exception<\/span><span style=\"font-family:\u5b8b\u4f53\">\u662f\u5f02\u5e38\u7684\u7c7b\u578b\uff08\u4f8b\u5982\uff0c<\/span><span style=\"font-family:Verdana\">NameError<\/span><span style=\"font-family:\u5b8b\u4f53\">\uff09\u53c2\u6570\u662f\u4e00\u4e2a\u5f02\u5e38\u53c2\u6570\u503c\u3002\u8be5\u53c2\u6570\u662f\u53ef\u9009\u7684\uff0c\u5982\u679c\u4e0d\u63d0\u4f9b\uff0c\u5f02\u5e38\u7684\u53c2\u6570\u662f<\/span><span style=\"font-family:Verdana\">&#8220;None&#8221;<\/span><span style=\"font-family:\u5b8b\u4f53\">\u3002<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u6700\u540e\u4e00\u4e2a\u53c2\u6570\u662f\u53ef\u9009\u7684\uff08\u5728\u5b9e\u8df5\u4e2d\u5f88\u5c11\u4f7f\u7528\uff09\uff0c\u5982\u679c\u5b58\u5728\uff0c\u662f\u8ddf\u8e2a\u5f02\u5e38\u5bf9\u8c61\u3002<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    raise TypeError(&#8216;\u7c7b\u578b\u9519\u8bef&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except Exception as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">\u7c7b\u578b\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\u00a0<br \/>\n\u00a0<\/p>\n<ul>\n<li>\n<div style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u81ea\u5b9a\u4e49\u5f02\u5e38<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t\t\t<\/span><\/span><\/div>\n<\/li>\n<\/ul>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python320.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">class hexinException(BaseException):<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    def __init__(self,msg):<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">        self.msg=msg<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    def __str__(self):<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">        return self.msg<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\">\n\u00a0<\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">try:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    raise hexinException(&#8216;\u7c7b\u578b\u9519\u8bef&#8217;)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">except hexinException as e:<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">    print(e)<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><img decoding=\"async\" src=\"\/wp-content\/uploads\/2017\/10\/101717_0303_Python321.gif\" alt=\"\"\/><span style=\"color:black; font-family:Verdana; font-size:10pt\"><br \/>\n\t\t<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-size:10pt\"><span style=\"font-family:\u5b8b\u4f53\">\u8f93\u51fa<\/span><span style=\"font-family:Verdana\"><br \/>\n\t\t\t<\/span><\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:\u5b8b\u4f53; font-size:12pt\">\u7c7b\u578b\u9519\u8bef<br \/>\n<\/span><\/p>\n<p style=\"background: #fefef2\"><span style=\"color:black; font-family:Verdana; font-size:10pt\">\u00a0<br \/>\n<\/span>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u9519\u8bef\u548c\u5f02\u5e38 1.\u9519\u8bef \u4ee3\u7801&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,10],"tags":[],"class_list":["post-944","post","type-post","status-publish","format-standard","hentry","category-python","category-jishu"],"_links":{"self":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/944"}],"collection":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=944"}],"version-history":[{"count":1,"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/944\/revisions"}],"predecessor-version":[{"id":977,"href":"http:\/\/alextop.top\/index.php?rest_route=\/wp\/v2\/posts\/944\/revisions\/977"}],"wp:attachment":[{"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=944"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/alextop.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}