【发布时间】:2012-08-05 15:22:46
【问题描述】:
from glob import glob
from os.path import isfile
def countwords(fp):
with open(fp) as fh:
return len(fh.read().split())
print "There are" ,sum(map(countwords, filter(isfile, glob("*.txt") ) ) ), "words in the files."
在第一行,为什么不直接导入 glob 库?
在“import glob”前面使用“from glob”有什么理由吗?
【问题讨论】: