给定一个简单的类,比如 def __init__(self, value): def _return [round(x,*n) for x in self.value]
为什么abs(Vector([-3,4]))可以正确地生成5,而round(Vector([-3.1,4]))报告的是TypeError: a float is required而不是所需的
我希望覆盖python的默认循环()函数,因为我必须将循环()函数的结果转换为整数。默认情况下,float ()以浮点数返回值。下面给出的代码是返回错误消息。RuntimeError:调用对象时超过了最大递归深度 if type(number) is float: return int(round(number