- import os
-
- #获取当前路径
- print os.path.dirname(os.path.abspath(__file__))
-
- <pre name="code" class="python">#获取当前路径
print os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
- #获取上级目录
- print os.path.abspath(os.path.join(os.path.dirname(__file__),".."))
- <pre name="code" class="python">#获取当前路径
print os.getcwd()
- <pre name="code" class="python">#获取上级目录
print os.path.dirname(os.getcwd())
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。