{"id":312705,"date":"2021-01-15T00:28:05","date_gmt":"2021-01-14T16:28:05","guid":{"rendered":"http:\/\/4563.org\/?p=312705"},"modified":"2021-01-15T00:28:05","modified_gmt":"2021-01-14T16:28:05","slug":"%e5%be%ae%e8%bd%af%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%9a%e7%ae%80%e5%8c%96%e8%b7%af%e5%be%84","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=312705","title":{"rendered":"\u5fae\u8f6f\u9762\u8bd5\u9898\uff1a\u7b80\u5316\u8def\u5f84"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5fae\u8f6f\u9762\u8bd5\u9898\uff1a\u7b80\u5316\u8def\u5f84               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zzzrf <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<h3>\u63cf\u8ff0<\/h3>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84(Unix-style)\uff0c\u8bf7\u8fdb\u884c\u8def\u5f84\u7b80\u5316\u3002 Unix \u4e2d, . \u8868\u793a\u5f53\u524d\u76ee\u5f55, .. \u8868\u793a\u7236\u76ee\u5f55\u3002 \u7ed3\u679c\u5fc5\u987b\u4ee5 \/ \u5f00\u5934\uff0c\u5e76\u4e14\u4e24\u4e2a\u76ee\u5f55\u540d\u4e4b\u95f4\u6709\u4e14\u53ea\u6709\u4e00\u4e2a \/\u3002\u6700\u540e\u4e00\u4e2a\u76ee\u5f55\u540d(\u5982\u679c\u5b58\u5728)\u540e\u4e0d\u80fd\u51fa\u73b0 \/ \u3002\u4f60\u9700\u8981\u4fdd\u8bc1\u7ed3\u679c\u662f\u6b63\u786e\u8868\u793a\u8def\u5f84\u7684\u6700\u77ed\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<ul>\n<li>\u4f60\u662f\u5426\u8003\u8651\u4e86 \u8def\u5f84\u4e3a &#8220;\/..\/&#8221; \u7684\u60c5\u51b5\uff1f<\/li>\n<li>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u9700\u8fd4\u56de&#8221;\/&#8221;\u3002<\/li>\n<li>\u6b64\u5916\uff0c\u8def\u5f84\u4e2d\u4e5f\u53ef\u80fd\u5305\u542b\u53cc\u659c\u6760&#8217;\/&#8217;\uff0c\u5982 &#8220;\/home\/\/foo\/&#8221;\u3002<\/li>\n<li>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5e94\u8be5\u5ffd\u7565\u591a\u4f59\u7684\u659c\u6760\uff0c\u8fd4\u56de &#8220;\/home\/foo&#8221;\u3002<\/li>\n<\/ul>\n<p>\u5728\u7ebf\u8bc4\u6d4b\u5730\u5740<\/p>\n<h3>\u6837\u4f8b 1<\/h3>\n<pre><code>\u8f93\u5165: \"\/home\/\" \u8f93\u51fa: \"\/home\" <\/code><\/pre>\n<h3>\u6837\u4f8b 2<\/h3>\n<pre><code>\u8f93\u5165: \"\/a\/.\/..\/..\/c\/\" \u8f93\u51fa: \"\/c\" \u89e3\u91ca: \"\/\" \u6ca1\u6709\u4e0a\u7ea7\u76ee\u5f55, \"\/..\/\" \u7684\u7ed3\u679c\u5c31\u662f \"\/\". <\/code><\/pre>\n<h3>\u7528\u6808\u5904\u7406\u5373\u53ef<\/h3>\n<p>\u5c06\u539f\u5b57\u7b26\u4e32\u4ee5 &#8216;\/&#8217; \u5206\u9694, \u7136\u540e\u904d\u5386:<\/p>\n<ul>\n<li>\u9047\u5230\u6b63\u5e38\u7684\u76ee\u5f55\u540d, \u5165\u6808<\/li>\n<li>\u9047\u5230 &#8216;.&#8217; \u6216 \u7a7a\u540d\u79f0 (\u5bf9\u5e94 &#8220;\/\/&#8221;) \u5219\u5ffd\u7565<\/li>\n<li>\u9047\u5230 &#8220;..&#8221; \u5219\u4ece\u6808\u9876\u5f39\u51fa\u4e00\u4e2a\u5143\u7d20 (\u5982\u679c\u6808\u4e3a\u7a7a\u5219\u4e0d\u5f39\u6808, \u5bf9\u5e94 &#8220;\/..\/&#8221;) \u6700\u540e\u5c06\u6808\u4e2d\u7684\u5143\u7d20\u4ee5 &#8216;\/&#8217; \u8fde\u63a5\u5f97\u5230\u7ed3\u679c.<\/li>\n<\/ul>\n<pre><code>class Solution:     \"\"\"     @param path: the original path     @return: the simplified path     \"\"\"     def simplifyPath(self, path):         path = path.split('\/')         stack = []         for i in path:             if i == '..':                 if len(stack):                     stack.pop()             elif i != '.' and i != '':                 stack.append(i)         return '\/' + '\/'.join(stack) <\/code><\/pre>\n<p>\u66f4\u591a\u9898\u89e3\u53c2\u8003<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5fae\u8f6f\u9762\u8bd5\u9898\uff1a\u7b80\u5316\u8def\u5f84 \u8cc7\u6df1\u5927\u4f6c :&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\/312705"}],"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=312705"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/312705\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=312705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=312705"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=312705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}