code

class mytest():
    def __str__(self):
        return "hello" 
    def __repr__(self):
        return "world"

a=mytest()
print(a)
print(str(a))
print(repr(a))

outputs

macname@MacdeMBP Desktop % python3 test_0823.py 
hello
hello
world
macname@MacdeMBP Desktop % 

 

 

 

 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2021-12-01
  • 2021-07-21
  • 2022-12-23
  • 2021-09-22
  • 2022-02-24
  • 2021-09-10
猜你喜欢
  • 2022-12-23
  • 2022-03-10
  • 2021-07-06
  • 2022-12-23
  • 2021-11-09
  • 2021-09-09
相关资源
相似解决方案