切换到指定名字的目录,作为init文件,在别的文件中import该文件就可以完成切换目录
# 切换工作目录 import os current_path = os.getcwd() print(current_path) project_name = ‘project‘ current_path = current_path[:current_path.find(project_name) + len(project_name)] os.chdir(current_path) print(os.getcwd())
原文地址:https://www.cnblogs.com/zhangjian0092/p/12340793.html
时间: 2024-10-13 21:43:43