首页 > 解决方案 > python AttributeError:模块'math'没有属性'comb'

问题描述

当我尝试使用“comb”功能时出现错误:

$ python
Python 3.7.1 (default, Dec 14 2018, 13:28:58) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import math
>>> print(math.comb(6,49))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'math' has no attribute 'comb'
>>> 

标签: mathpython-3.7comb

解决方案


comb 函数是 Python 3.8 中的新功能(请参阅此处的文档)。你的 Python 安装是 3.7.1。如果您更新 Python 安装,则该问题应该得到解决。


推荐阅读