python文件查找
1、import glob shell干的就是glob在windows下 使用搜索*.py需要导入glob才可以进行*.py的搜索
glob.glob('*.py')返回以py结尾的列表
2、处理参数最方便的工具:
from optparse import OptionParser
3、os.path
os.path.dirname(sys.argv)
or
os.path.dirname(__file__)
os.path.curdir ----> 返回当前路径
os.path.isfile()
os.path.isdir()
os.path.abspath() 返回绝对路径
os.path.exists() 判断文件是否存在
os.path.join() 拼接路径 os.path.join('www','htdocs','index.html')
In : os.path.join('www','htdocs','index.html') # / 为默认
Out: 'www/htdocs/index.html'
os.path.splitext('fasdfa.html')
In : os.path.splitext('fasdfa.html')
Out: ('fasdfa', '.html')
页:
[1]