您的位置:首页 > 编程语言 > Python开发

python中获取当前路径【os模块】

2017-05-24 12:07 239 查看
本机windows,文件目录F:\python\ClStudyDemo\osTest.py



os.path.realpath(_file_)——返回真实路径

os.path.split()——返回路径的目录和文件名

os.getcwd()——得到当前工作的目录

__file__ 是用来获得模块所在的路径的

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


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: