发布时间:2019-08-20 07:47:09编辑:auto阅读(1942)
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[0])
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 [2]: os.path.join('www','htdocs','index.html') # / 为默认
Out[2]: 'www/htdocs/index.html'
os.path.splitext('fasdfa.html')
In [4]: os.path.splitext('fasdfa.html')
Out[4]: ('fasdfa', '.html')
上一篇: Python习题(一)
下一篇: python https实现方法
50506
49809
40410
37424
31845
28711
27639
22422
22421
20735
500°
1116°
911°
844°
1093°
967°
1583°
2947°
2628°
2020°