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
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