||
当前路径:
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)
上一路径
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
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-22 20:14
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社