【发布时间】:2022-11-16 21:23:53
【问题描述】:
如何解决 (TypeError: must be a real number, not a tuple) 错误
class Vehicle:
name = ""
kind = "car"
color = ""
value = 100.00
def description(self):
desc_str = "%s is a %s %s worth $%.2f." % (self.name, self.color, self.kind, self.value)
return desc_str
car1 = Vehicle()
car1.name = "Fer"
car1.color = "Red"
car1.kind = "Convertible"
car1.value = 60,000.00
car2 = Vehicle()
car2.name = "Jump"
car2.color = "Blue"
car2.kind = "Van"
car2.value = 10,000.00
print(car1.description())
print(car2.description())
运行此代码后,出现错误。我想要汽车的信息。
【问题讨论】:
-
如果你想把你的号码分成一些数字组,你可以在你的号码中使用
_。
标签: python-3.x