获取当前文件的路径和父路径(2级)-pycharm:
import os CURRENT_PATH = os.path.dirname(__file__) #返回当前文件所在的路径 ROOT_PATH = os.path.dirname(CURRENT_PATH) #获取当前路径的上级路径 print(CURRENT_PATH) print(ROOT_PATH)
获取当前文件的路径和父路径(2级)-pycharm:
import os CURRENT_PATH = os.path.dirname(__file__) #返回当前文件所在的路径 ROOT_PATH = os.path.dirname(CURRENT_PATH) #获取当前路径的上级路径 print(CURRENT_PATH) print(ROOT_PATH)