原版,自己脑补空格吧: 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
mengzhuo
2014-06-06 09:37:12 +08:00
t_join("/usr", "local", "share/resource")
*args 属于implicit,不符合Pythonic的Explicit 罚LZ import this