Python 打印当前文件绝对路径

一、打印相对路径

  print(__file__)

二、打印绝对路径

  import os 

  print(os.path.abspath(__file__))

三、打印文件名

  import os 

  print(os.path.dirname(os.path.abspath(__file__)))

猜你喜欢

转载自www.cnblogs.com/Presley-lpc/p/9383759.html