{"id":154347,"date":"2020-09-07T19:13:38","date_gmt":"2020-09-07T11:13:38","guid":{"rendered":"http:\/\/4563.org\/?p=154347"},"modified":"2020-09-07T19:13:38","modified_gmt":"2020-09-07T11:13:38","slug":"python-%e5%a6%82%e4%bd%95%e4%bc%98%e9%9b%85%e5%9c%b0%e5%a4%84%e7%90%86%e5%ad%90%e7%ba%bf%e7%a8%8b%e5%bc%82%e5%b8%b8%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=154347","title":{"rendered":"Python \u5982\u4f55\u4f18\u96c5\u5730\u5904\u7406\u5b50\u7ebf\u7a0b\u5f02\u5e38\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Python \u5982\u4f55\u4f18\u96c5\u5730\u5904\u7406\u5b50\u7ebf\u7a0b\u5f02\u5e38\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Te11UA <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u76ee\u524d\u6bd4\u8f83\u591a\u7684\u505a\u6cd5\u8fd8\u662f\u5982\u4e0b\uff0c\u51fa\u4e8e\u62c5\u5fc3\u672a\u77e5\u5f02\u5e38\u3001\u6ca1\u6709\u8bb0\u5f55\u65e5\u5fd7\u5c31\u9000\u51fa\u5b50\u7ebf\u7a0b\u7684\u60c5\u51b5\u4e0b\uff0c\u5728\u51fd\u6570\u7528\u4e00\u4e2a\u5927\u7684 try-except \u6765\u8fdb\u884c handle\uff0c\u6216\u8005\u662f\u5c06\u4e3b\u8981\u903b\u8f91\u653e\u5230 test_sth \u4e2d\uff0c\u4f7f\u7528 try-except \u6765\u6355\u83b7\uff1a<\/p>\n<pre><code>def run():     try:         test_sth()         ...     except Exception:         log_exception() Thread(target=run).start() <\/code><\/pre>\n<p>\u603b\u611f\u89c9\u5305\u88f9\u4e00\u5927\u5757\u4e0d\u592a\u7f8e\u89c2\u7684\u6837\u5b50\uff0c\u8bf7\u95ee\u8fd9\u6837\u662f\u6700\u4f73\u5b9e\u8df5\u4e86\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>3<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3246447\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : jdhao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7ebf\u7a0b\u91cc\u9762\u6355\u83b7\u5f02\u5e38\uff0c\u8fd4\u56de\u8fd0\u884c\u6210\u529f\u4e0e\u5426\u7684\u6807\u5fd7\uff1f\u4f4f\u8fdb\u7a0b\u6839\u636e\u8fd9\u4e2a\u518d\u505a\u5904\u7406                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3246448\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : black11black <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5f02\u5e38\u6355\u6349\u4f60\u80af\u5b9a\u5f97 try except \u554a\uff0c\u5305\u88f9\u4e00\u5927\u5757\u662f\u80af\u5b9a\u7684\uff0c\u552f\u4e00\u4e0d\u723d\u5199\u6cd5\u4e0a\u7684\u6539\u53d8\u4f60\u53ef\u4ee5\u7528\u88c5\u9970\u5668\u3002<\/p>\n<p>logging \u4f1a\u81ea\u52a8\u5904\u7406\u591a\u7ebf\u7a0b\u76f8\u5173\uff0c\u4f46\u662f\u4f60\u8fd9\u4e48\u641e\u7ebf\u7a0b\u81ea\u5df1\u5904\u7406\u5f02\u5e38\u800c\u4e0d\u662f\u96c6\u4e2d\u5230\u4e3b\u7ebf\u7a0b\uff0c\u5b8c\u5168\u6ca1\u6709\u63a7\u5236\uff0c\u6ca1\u4ec0\u4e48\u610f\u4e49                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3246449\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dongxiao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f7f\u7528\u88c5\u9970\u5668\uff0c\u628a\u6355\u83b7\u903b\u8f91\u63d0\u53d6\u51fa\u6765                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Python \u5982\u4f55\u4f18\u96c5\u5730\u5904\u7406\u5b50\u7ebf\u7a0b&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/154347"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=154347"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/154347\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=154347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=154347"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=154347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}