获取当前目录,上级目录,上上级目录

import os

print('当前目录')
print(os.getcwd())

print('上级目录')
print(os.path.dirname(file_path))

print('上上级目录‘)
print(os.path.dirname(os.path.dirname(file_path)))

参考:
[1] https://www.jianshu.com/p/dde02a88a5c1

posted @ 2023-02-15 10:46  xiaoxuxli  阅读(20)  评论(0编辑  收藏  举报