本機windows,文件目錄F:\python\ClStudyDemo\osTest.py
os.path.realpath(_file_)——返回真實路徑
os.path.split()——返回路徑的目錄和文件名
os.getcwd()——得到當前工作的目錄
__file__ 是用來獲得模塊所在的路徑的
print(os.path.realpath(__file__)) print(os.path.split(os.path.realpath(__file__))) print(os.getcwd())