
1 liluo Jun 5, 2014 import os os.path.join("/usr", "local", "share/resource") |
3 jarlyyn Jun 5, 2014 感觉这是js风格,不是python风格 |
4 keakon Jun 6, 2014 @dbow 逻辑错了 原版,自己脑补空格吧: def join(a, *p): """Join two or more pathname components, inserting '/' as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.""" path = a for b in p: if b.startswith('/'): path = b elif path == '' or path.endswith('/'): path += b else: path += '/' + b return path |
5 mengzhuo Jun 6, 2014 t_join("/usr", "local", "share/resource") *args 属于implicit,不符合Pythonic的Explicit 罚LZ import this |