0、前言
首先要导入os模块
import os
1、返回当前文件的绝对路径
abspath = os.path.abspath(__file__)
print(abspath)
结果:
D:\python_spider\python_spider_lt\更新当天数据.py
2、返回当前文件所在的目录
dirname = os.path.dirname(__file__)
print(dirname)
本文持续更新中,用到什么更新什么
微信扫一扫
首先要导入os模块
import os
abspath = os.path.abspath(__file__)
print(abspath)
结果:
D:\python_spider\python_spider_lt\更新当天数据.py
dirname = os.path.dirname(__file__)
print(dirname)
本文持续更新中,用到什么更新什么
相关推荐