参考代码
import os
os.path.abspath('')
REF
os.path.abspath(.)及os.getcwd()获取的是当前工作目录所在文件夹,并不是该py文件所在文件夹
py文件目录
current_address_1 = os.path.dirname(os.path.abspath(__file__))
当前工作目录
current_address_2 = os.path.abspath('.')
current_address_3 = os.getcwd()
https://blog.csdn.net/zishendianxia/article/details/106062911
If you want to get path of the directory in which your script is running, I would highly recommend using,
os.path.abspath('')
https://stackoverflow.com/questions/39125532/file-does-not-exist-in-jupyter-notebook