Is there a version of os.getcwd() that doesn't dereference symlinks? [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How to get/set logical directory path in python 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. Does Python have a command for that? 回答1: Workaround: os.getenv('PWD') 回答2: In general this is