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