三种方法 1、os.path.dirname(os.path.abspath(".")) 2、os.path.dirname(os.getcwd())这个包含了文件的路径 3、os.path.dirname(__file__)