python获取工作相对路径

import os

# 查看当前工作目录
print("Current working directory:", os.getcwd())

# 如果需要切换到脚本所在的目录
script_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(script_dir)    


posted on 2024-10-28 01:03  lydstory  阅读(12)  评论(0)    收藏  举报

导航