因此,我有需要使用Concurrent.futures模块的代码,出于某种原因,它告诉我它不存在。我已经查过了,我找不到问题所在。我试着安装我需要的工具,以为是这样的,但我只能下载其中一个工具。错误消息:
从concurrent.futures导入ProcessPoolExecutor ModuleNotFoundError:没有一个模块名为“concurrent.fusion”;“并发”不是一个包
我的代码:
import requests, time
from concurrent.futures import ProcessPoolExecutor
sites = ["http://www.youtube.com"]
def get_one(site):
resp = requests.get(site)
size = len(resp.content)
print(f"download {site} bytes from {site}")
return size
def main():
total_size = 0
start = time.perf_counter()
with ProcessPoolExecutor as exec:
total_size = sum(exec.map(get_one, sites))
end = time.perf_counter()
for site in sites:
total_size += size
#print(f"downlded {size} bytes from {site}")
#end = time.perf_counter()
print(f"elapsed time: {end - start} seconds")
print (f"downloaded a totla of {total_size} bytes")
if __name__== "__main__":
main()我知道当我说“开始”的时候,通常应该有一个文件,但是我查到的所有东西都说concurrent.futures是python的一部分,但出于某种原因,我的文件不能正常工作。如果它在外面,我必须安装它吗?
发布于 2021-05-04 15:40:22
我发现我的文件夹中有一个名为concurrent.py的文件,它把一切都搞砸了!
https://stackoverflow.com/questions/67378624
复制相似问题