from functools import reduce
我使用python 3.6.2,这是显示以下错误的唯一代码:python3.6导入错误:无法导入名称“减少”
Traceback (most recent call last): File "D:\Pythons\oop.py", line 50, in from functools import reduce
ImportError: cannot import name 'reduce' Process returned 1 (0x1) execution time : 0.145 s
我会找到这个问题因为我在做另一个代码错误,
from enum import Enum
它报告的错误:
Traceback (most recent call last): File "D:\Pythons\oop.py", line 50, in from enum import Enum File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\enum.py", line 3, in from functools import reduce ImportError: cannot import name 'reduce'
所以我只是看着enum. Py
源,在3线
from functools import reduce
女士们,先生们发现,在centos7.2安装python3.6.2完全是出于什么问题,但在安装了Windows 10专业版,会出现上面的这些问题,好像我安装了这个问题,但是,很多次我卸载了,反复安装了很多次,还是不行,不知道没有这些文件,谁能告诉我如何通过在Windows环境下的命令行来安装它?
所以Python不能从'functools'导入'reduce'。我无法在python 3中找到名为reduce的类/方法。https://github.com/python/cpython/blob/3.6/Lib/functools.py - 这是在Python 2中可用的https:// docs。 python.org/2/library/functools.html#functools.reduce –
该代码在https://www.python.org/shell/上使用版本3.6.0时正常工作。也许重新安装,或使用所有python软件包进行完整安装? – Sheldon
我刚刚安装了3.6.2,我无法复制。 'reduce'甚至列在[文档页面](https://docs.python.org/3/library/functools.html#functools.reduce) – Wondercricket