Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1634118
  • 博文数量: 126
  • 博客积分: 1541
  • 博客等级: 上尉
  • 技术积分: 1914
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-20 11:14
文章分类

全部博文(126)

文章存档

2014年(21)

2013年(42)

2012年(63)

分类:

2013-01-06 22:33:30

原文地址:python os.path.sep 作者:Jiker4836

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. >>>
>>> a
[1, 2, 3]
>>> b=[]
>>> b=map(int,a)
>>> b
[1, 2, 3]
>>> b=map(float,a)
>>> b
[1.0, 2.0, 3.0]
>>> 

阅读(4173) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~