Chinaunix首页 | 论坛 | 博客
  • 博客访问: 759262
  • 博文数量: 231
  • 博客积分: 3217
  • 博客等级: 中校
  • 技术积分: 2053
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-04 12:01
文章分类

全部博文(231)

文章存档

2015年(1)

2013年(10)

2012年(92)

2011年(128)

分类: LINUX

2012-09-05 14:33:22

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]
>>> 

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