Python 获取文件路径及文件目录
import os print (os.path.dirname(__file__)) print (os.path.abspath(__file__)) print (os.path.abspath(os.path.dirname(__file__))) print (os.path.dirname(os.path.abspath(__file__)))
import os print (os.path.dirname(__file__)) print (os.path.abspath(__file__)) print (os.path.abspath(os.path.dirname(__file__))) print (os.path.dirname(os.path.abspath(__file__)))