判断字符串a是否以字符串b开头或结尾
使用字符串的 str.startwith() 和 str.endswith()方法
import os , stat
for name in os.listdir('.') if name.endswith('py','sh')
调整字符串中文本的格式
import re
log = open('/var/log/dkpg.log').read()
print re.sub(('\d{4}-\d{2}-\d{2}'),r'\2/\3/\1',log)