【OS用法详解】os.path.abspath(__file__)&os.path.dirname()&os.path.basename(__file__)&os.path.join()

os.path.用法详解

  • `os.path.abspath(__file__)`
  • os.path.dirname()
  • `os.path.basename(__file__)`
  • os.path.join()

os.path.abspath(__file__)

os.path.dirname(__file__):返回脚本的绝对路径

import os

print(os.path.abspath(__file__))
D:\Python\PycharmProjects\pythonProject\crawl\os.path.测试

你可能感兴趣的:(Python,python,pycharm,开发语言)