gll89的个人博客分享 http://blog.sciencenet.cn/u/gll89

博文

Python 当前路径与上一路径

已有 1774 次阅读 2019-7-26 11:56 |个人分类:Python|系统分类:科研笔记

  1. 当前路径:

    cur_dir= os.getcwd()   # This outputs the absolute path

    cur_dir = os.curdir()    # This outputs '.'

                                       # In order to get the absolute path, using os.path.abspath(curdir)

  2. 上一路径

    par_dir_relative = os.path.join(os.curdir(), os.pardir())   # os.pardir() is '..' for Windows

                                                                                           # This outputs .\\..

    par_dir = os.path.abspath(par_dir_relative)   # This outputs the absolute path of the parent path

                                             #os.path.abspath: transfer the relative path to absolute path



https://blog.sciencenet.cn/blog-1969089-1191153.html

上一篇:连接远程Ubuntu服务器
下一篇:[转载]大数据遍历一遍同时求出均值与标准差
收藏 IP: 60.191.2.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-26 04:43

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部