Python的夹七夹八
Python的杂七杂八
1. 读取文件列表
import os print os.listdir('.') files = [f for f in os.listdir('.') if re.match("*.jpg", f) ]
2. 读取文件自动关闭
with open(filename) as file: for line in file: print line