是否有不解引用符号链接的os.getcwd()版本? [英] Is there a version of os.getcwd() that doesn't dereference symlinks?

查看:94
本文介绍了是否有不解引用符号链接的os.getcwd()版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何在python中获取/设置逻辑目录路径

Possible Duplicate:
How to get/set logical directory path in python

我有一个从符号链接目录运行的Python脚本,我在其中调用os.getcwd(),以期获得我运行它的符号链接路径.相反,它为我提供了真实"的路径,在这种情况下这没有帮助.我需要它才能真正给我符号链接的版本.

I have a Python script that I run from a symlinked directory, and I call os.getcwd() in it, expecting to get the symlinked path I ran it from. Instead it gives me the "real" path, and in this case that's not helpful. I need it to actually give me the symlinked version.

Python对此有命令吗?

Does Python have a command for that?

推荐答案

解决方法:os.getenv('PWD')

这篇关于是否有不解引用符号链接的os.getcwd()版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆