import os print '***獲取當前目錄***' print os.getcwd() print os.path.abspath(os.path.dirname(__file__)) print '***獲取上級目錄***' print os.path.abspath(os.path.dirname(os.path.abspath(os.path.dirname(__file__)))) print os.path.abspath(os.path.dirname(os.getcwd())) print os.path.abspath(os.path.join(os.getcwd(), "..")) print '***獲取上上級目錄***' print os.path.abspath(os.path.join(os.getcwd(), "../.."))