1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| >>> class Time:
"Nouvelle classe temporelle"
def affiche_heure(self):
print str(self.heure) + ":" + str(self.minute) \
+ ":" + str(self.seconde)
>>> maintenant = Time()
>>> maintenant.heure = 13
>>> maintenant.seconde = 21
>>> maintenant.seconde = 21
>>> maintenant.affiche_heure()
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
maintenant.affiche_heure()
File "<pyshell#0>", line 5, in affiche_heure
+ ":" + str(self.seconde)
AttributeError: Time instance has no attribute 'minute' |
Partager