1>>> class Test:
2... def __repr__(self):
3... return "Test()"
4... def __str__(self):
5... return "member of Test"
6...
7>>> t = Test()
8>>> t
9Test()
10>>> print(t)
11member of Test
1
2class Person:
3 name = ""
4 age = 0
5
6 def __init__(self, personName, personAge):
7 self.name = personName
8 self.age = personAge
9
10 def __repr__(self):
11 return {'name':self.name, 'age':self.age}
12
13 def __str__(self):
14 return 'Person(name='+self.name+', age='+str(self.age)+ ')'
15