AttributeError:“unicode”对象没有属性“add”运算符Modu

2024-06-02 05:03:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一本字典,我用操作员模块来做。它看起来是这样的:

           ops =  {"+": operator.add,
                   "-": operator.sub,
                   "*": operator.mul,
                   "/": operator.div}

但是,当我运行程序时,我得到了一个错误:

AttributeError: 'unicode' object has no attribute 'add'

我该怎么解决这个问题?在


Tags: 模块no程序divadd字典object错误