Python 如何在类中打印int值?

Python 如何在类中打印int值?,python,Python,我目前正在学习用python创建一个类。我在中输入了一个int值,但它似乎根本没有打印出int值。我做错什么了吗? 这是我当前的代码: class Cars: def __init__ (self, model, Type, price): self.model = 'Model:'+ model self.Type= 'Type:'+ Type self.price= price def fullname(self):

我目前正在学习用python创建一个类。我在中输入了一个int值,但它似乎根本没有打印出int值。我做错什么了吗? 这是我当前的代码:

class Cars:
    def __init__ (self, model, Type, price):
        self.model  = 'Model:'+ model
        self.Type= 'Type:'+ Type
        self.price= price

    def fullname(self):
        return '{} {}'.format(self.model, self.Type)

    def Price(self):
        return 'Price:'.format(self.price)


car_1= Cars('CLA','Coupe', 34000)
car_2= Cars('GLA','SUV', 38000)

print(Cars.fullname(car_1))
print(car_1.Price())
print(car_2.fullname())
print(car_2.Price())
输出:

Model:CLA Type:Coupe
Price:
Model:GLA Type:SUV
Price:
我想打印价格下的价格值

如果有人能帮忙,我将不胜感激。如果有类似问题的链接,请尽可能链接。谢谢。

你错过了{}。看

此外,您命名的方法价格与成员价格非常相似

如果您想告诉类打印值,那么应该调用类似printPrice的方法。用描述动作的东西来命名方法是一种很好的做法。 如果您只想获得成员,请使用。。 如果在返回成员之前确实需要对其执行某些操作,也就是说,希望将类的内部工作隐藏到外部,那么使用。但这是更先进的,应该只在真正需要时使用。
谢谢你的建议。谢谢我会记住的。
def Price(self):
    return 'Price: {}'.format(self.price)