我有以下内容:
a = "/my/absolute/path"
b = "my/relative/path"
root = "/new/root/dir"
print relocate_path(a, root)
print relocate_path(b, root)
我想得到:
/new/root/dir/my/absolute/path
/new/root/dir/my/relative/path
如何以relocate_path
pythonic方式有效地实现?标准库中有类似的东西吗?(我在os.path中尝试过,但一无所获)