가능한 중복 : 첫 번째 줄에
'import module' or 'from module import'
from … import
vsimport .
나는 파이썬 '에서'을 이해하지 못하는
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 라이브러리 가져 오기?
"glob from"을 "import glob"앞에 사용할 이유가 있습니까? ,
from glob import iglob
아마도 더 좋을 수도 있습니다. http://stackoverflow.com/questions/710551/import-module-or-from-module-import –