0、前言 首先要导入os模块 import os 1、返回当前文件的绝对路径 abspath = os.path.abspath(__file__) print(abspath) 结果: D:\python_spider\python_spider_lt\更新当天数据.py