python获取当前目录及其父目录

import os

current_directory = os.getcwd()
parent_directory = os.path.dirname(current_directory)

print("当前目录:", current_directory)
print("上一级目录:", parent_directory)
posted on 2024-07-29 10:12  大海z16  阅读(6)  评论(0编辑  收藏  举报