类型错误:“int"对象不可调用 [英] TypeError: 'int' object is not callable

查看:134
本文介绍了类型错误:“int"对象不可调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定以下整数和计算

from __future__ import division

a = 23
b = 45
c = 16

round((a/b)*0.9*c)

结果:

TypeError: 'int' object is not callable.

如何将输出四舍五入为整数?

How can I round the output to an integer?

推荐答案

在你的代码的其他地方,你有这样的东西:

Somewhere else in your code you have something that looks like this:

round = 42

然后当你写

round((a/b)*0.9*c)

被解释为对绑定到round的对象的函数调用,它是一个int.那失败了.

that is interpreted as meaning a function call on the object bound to round, which is an int. And that fails.

问题在于任何代码将 int 绑定到名称 round.找到并删除它.

The problem is whatever code binds an int to the name round. Find that and remove it.

这篇关于类型错误:“int"对象不可调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆