python - os.path,路径相关操作

python处理系统路径的相关操作:

# -*- coding: utf-8 -*-
 
import os
 
# 属性
print '__file__: %s' % __file__ # 绝对路径(包含文件名) abspath = os.path.abspath(__file__) print('abspath: %s' % abspath)
# 路径(剔除文件名) dirname
= os.path.dirname(abspath) print('dirname: %s' % dirname)

 

posted @ 2014-03-07 13:25  kv9  阅读(190)  评论(0编辑  收藏  举报