标签:sep print dirname etc tor deb ase ant charm
import os pwd = os.getcwd() print("当前目录: " + pwd) father_path_method1 = os.path.dirname(pwd) print("当前目录的父目录_方式一: " + father_path_method1) separator = os.path.sep print("系统目录分隔符: " + separator) father_path_method2=os.path.abspath(os.path.dirname(pwd)+os.path.sep+".") print("当前目录的父目录_方式二:" + father_path_method2) http_case_path = os.path.join(os.path.dirname(pwd),"httpCase") print("http_case_path: " + http_case_path)
输出结果如下:
当前目录: E:\HP\PycharmProjects\JDMerchant\debug
当前目录的父目录_方式一: E:\HP\PycharmProjects\JDMerchant
系统目录分隔符: 当前目录的父目录_方式二:E:\HP\PycharmProjects\JDMerchant
http_case_path: E:\HP\PycharmProjects\JDMerchant\httpCase
标签:sep print dirname etc tor deb ase ant charm
原文地址:https://www.cnblogs.com/pandaly/p/13206652.html