Python:计算从一个目录到另一个目录的相对路径 [英] Python: Compute relative path from one directory to another
本文介绍了Python:计算从一个目录到另一个目录的相对路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何计算2个目录路径之间的相对路径?
我需要计算从一个目录到另一个目录的相对路径(即我设置一个相对于工作目录的路径,并且想要计算任何父/子目录的相对路径)。在Python中做什么好的方法?我不太了解这个问题。
I need to compute the relative path from one directory to another (i.e. I set a path relative to the working directory, and want to compute the according relative path from any parent/subdir). What is a good way to do that in Python? I could not find much on the subject.
谢谢!
推荐答案
您应该看看: os.path.relpath
You should take a look at: os.path.relpath
这篇关于Python:计算从一个目录到另一个目录的相对路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文