{"id":149601,"date":"2020-08-30T06:35:12","date_gmt":"2020-08-29T22:35:12","guid":{"rendered":"http:\/\/4563.org\/?p=149601"},"modified":"2020-08-30T06:35:12","modified_gmt":"2020-08-29T22:35:12","slug":"python-%e5%a6%82%e4%bd%95%e5%b0%86%e6%96%87%e4%bb%b6%e8%b7%af%e5%be%84%e5%88%97%e8%a1%a8%e8%bf%9b%e8%a1%8c%e5%bd%92%e7%b1%bb%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=149601","title":{"rendered":"Python \u5982\u4f55\u5c06\u6587\u4ef6\u8def\u5f84\u5217\u8868\u8fdb\u884c\u5f52\u7c7b\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Python \u5982\u4f55\u5c06\u6587\u4ef6\u8def\u5f84\u5217\u8868\u8fdb\u884c\u5f52\u7c7b\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : coolair <\/span>  <span><i><\/i> 9<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>list_a = ['\/usr\/bin\/a.sh', '\/usr\/bin\/b.sh', '\/usr\/c.sh', '\/usr\/d.sh', '\/bin\/a.sh', '\/bin\/b.sh', '\/bin\/test\/a.sh', '\/bin\/test\/c.sh']  ===&gt;  result = [['\/usr\/bin\/a.sh', '\/usr\/bin\/b.sh'], [ '\/usr\/c.sh', '\/usr\/d.sh'], ['\/bin\/a.sh', '\/bin\/b.sh'], ['\/bin\/test\/a.sh', '\/bin\/test\/c.sh']] <\/code><\/pre>\n<p>\u4e5f\u5c31\u662f\u628a\u76ee\u5f55\u76f8\u540c\u7684\u6587\u4ef6\u8def\u5f84\u5f52\u5230\u4e00\u4e2a\u5b50\u5217\u8868\u4e2d\uff0c\u5982\u4f55\u64cd\u4f5c\u66f4\u9ad8\u6548\u554a\uff0c\u8c22\u8c22\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3142972\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : imn1 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5148\u8ba2\u5c42\u7ea7<br \/>\/\u76f8\u540c 15 \u5c42 \/a<br \/>\/\u76f8\u540c 15 \u5c42 \/b\/a<br \/>\u8fd9\u4e24\u4e2a\u7b97\u4e00\u7c7b\u8fd8\u662f\u4e24\u7c7b\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3142973\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BBrother <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6839\u636e&#8221;\/&#8221;\u5207\u5206\uff0c\u5207\u51fa\u6765\u7684\u6bcf\u4e00\u90e8\u5206\u90fd\u662f\u4e00\u4e2a\u8282\u70b9\uff0c\u4ee5\u7c7b\u4f3c trie \u7684\u601d\u8def\u5efa\u6811\uff0c\u6240\u6709\u975e\u53f6\u5b50\u8282\u70b9\u5c31\u662f\u4f60\u8981\u7684\u5b50\u76ee\u5f55                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3142974\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ungrown <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8def\u5f84\u6240\u6709 part \u5168\u90e8\u5272\u5f00\uff0c\u7136\u540e\u8fed\u4ee3\u653e\u5165\u591a\u5c42\u7ea7\u7684\u5b57\u5178                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3142975\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : coolair <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @imn1 #1 \u4e24\u7c7b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3142976\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : imn1 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u53ea\u8ba1\u7b97 basename \u548c dirname \u5c31\u7b80\u5355<br \/>dirs = {dirname(x) for x in list_a}<br \/>result = [[x for x in list_a if x.startswith(y+&#8217;\/&#8217;)] for y in dirs]                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Python \u5982\u4f55\u5c06\u6587\u4ef6\u8def\u5f84\u5217\u8868\u8fdb&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\/149601"}],"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=149601"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/149601\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=149601"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=149601"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=149601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}