我正在研究一些面向对象的编程。不幸的是,我什至无法迈出第一步。使用str将类转换为字符串。这是我的代码:
class Time:
def __init__(self, hours = 0, minutes = 0, seconds = 0):
self.hours = hours
self.minutes = minutes
self.seconds = seconds
def __str__(self):
return "basdfadsg"
time1 = Time
time1.hours = 3
time1.minutes = 23
time1.seconds = 13
print(time1)
每当我尝试
print(time1)
它返回
<class '__main__.Time'>
我究竟做错了什么?
任何帮助,将不胜感激!