Can't convert 'int' object to str implicitly提示解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37806112/article/details/85951415

eg:

class Car:
    def __init__(self, newWheelNum, newColor):
        self.wheelNum = newWheelNum
        self.color = newColor
    def __str__(self):
        msg = "嘿。。。我的颜色是" + self.color + "我有" + self.wheelNum + "个轮胎..."
        return msg
    def move(self):
        print('车在跑,目标:夏威夷')
hellocar = Car(4, "白色")
print(hellocar)

   

修改:

  

猜你喜欢

转载自blog.csdn.net/m0_37806112/article/details/85951415