这个CODE AttributeError中出了什么问题:'模块'对象没有属性' div'

时间:2015-08-20 08:12:44

标签: python

我创建了一个名为" cal.py"的模块。

import math    
import operator

def add(a, b):
    return a + b

def subtraction(a, b):
    return a - b

def mul(a, b):
    return a * b

def div(a, b):
    return a / b

当我尝试在python intrepreter中执行以下操作时

>>cal.div(10, 2)

它的节目

AttributeError: 'module' object has no attribute 'div'

然而,对于add(),我给出了正确答案

>>cal.add(4, 7)
11

0 个答案:

没有答案