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__)))

  

原文地址:https://www.cnblogs.com/royfans/p/7908009.html