python的目录

1.python的当前目录

d = os.path.dirname(__file__) #和文件强依赖,即使该语句被别的文件调用,d也不会改变
或者
d = os.getcwd() #当该语句被别的文件调用时,d就是别的文件的目录.(雷区)

2.父目录

parent_path = os.path.dirname(d)
新战场:https://blog.csdn.net/Stephen___Qin
原文地址:https://www.cnblogs.com/Stephen-Qin/p/10243473.html