1
liluo 2014-06-05 21:02:23 +08:00
import os
os.path.join("/usr", "local", "share/resource") |
3
jarlyyn 2014-06-05 22:01:21 +08:00
感觉这是js风格,不是python风格
|
4
keakon 2014-06-06 01:28:54 +08:00
@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 2014-06-06 09:37:12 +08:00
t_join("/usr", "local", "share/resource")
*args 属于implicit,不符合Pythonic的Explicit 罚LZ import this |
6
yueyoum 2014-06-06 10:19:20 +08:00
|