gpt4 book ai didi

python - 我不明白 Python 中的 'from'

转载 作者:行者123 更新时间:2023-11-28 19:33:33 25 4
gpt4 key购买 nike

<分区>

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”是否有任何理由?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com