公有属性与私有属性
太好了!您的同事决定在他们正在开发的银行应用中使用面向对象编程。现在他们需要您帮忙实现其中一个类,这将同时用到公有属性和私有属性。
本练习是课程的一部分
编程范式概念
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Define the Car class
class Car():
def __init__(self, price):
# price is a public attribute
self.____ = price