【发布时间】:2021-11-19 18:06:00
【问题描述】:
当我使用打印功能时,我想打印关于我的对象的信息!
如果我打印 (my_product),它会显示 Product(name = the_name)。
我的班级:
class Product:
def __init__(self, name = ""):
self._name = name
@property
def name(self):
return self._name
例如:
my_product = Product("Computer")
print(my_product)
#Product(name=Computer)
你能帮帮我吗?
【问题讨论】:
-
您希望输出是什么?
标签: python python-3.x