美文网首页
Python获取当前文件夹路径

Python获取当前文件夹路径

作者: nick5683 | 来源:发表于2021-04-27 17:09 被阅读0次

import os

import sys

print("sys.path[0] = ", sys.path[0])

print("sys.argv[0] = ", sys.argv[0])

print("__file__ = ", __file__)

print("os.path.abspath(__file__) = ", os.path.abspath(__file__))

print("os.path.realpath(__file__) = ", os.path.realpath(__file__))

print("os.path.dirname(os.path.realpath(__file__)) = ",

os.path.dirname(os.path.realpath(__file__)))

print("os.path.split(os.path.realpath(__file__)) = ",

os.path.split(os.path.realpath(__file__)))

print("os.path.split(os.path.realpath(__file__))[0] = ",

os.path.split(os.path.realpath(__file__))[0])

print("os.getcwd() = ", os.getcwd())

相关文章

网友评论

      本文标题:Python获取当前文件夹路径

      本文链接:https://www.haomeiwen.com/subject/ynkprltx.html