python os.path.sep

来源:互联网 发布:app建站 编辑:程序博客网 时间:2024/05/19 10:35
python中os.path常用模块
os.path.sep:路径分隔符 linux下就用这个了’/’
os.path.altsep: 根目录
os.path.curdir:当前目录
os.path.pardir:父目录
os.path.abspath(path):绝对路径
os.path.join(): 常用来链接路径
os.path.split(path): 把path分为目录和文件两个部分,以列表返回

 

  1. [GCC 4.4.5] on linux2
  2. Type "help", "copyright", "credits" or "license" for more information.
  3. >>> import os
  4. >>> help('os.path.sep')

  5. >>> print os.path.sep
  6. /
  7. >>> print os.path.altsep
  8. None
  9. >>> print os.path.curdir
  10. .
  11. >>> print os.path.abspath('/root')
  12. /root
  13. >>> print os.path.abspath('/root/pp')
  14. /root/pp
  15. >>> print os.path.abspath('/root/pp/f.c')
  16. /root/pp/f.c
  17. >>> print os.path.split('/root/pp/f.c')
  18. ('/root/pp', 'f.c')
  19. >>>
0 0
原创粉丝点击