How to print instances of a class using print()?

前端 未结 9 1823
南方客
南方客 2020-11-21 07:27

I am learning the ropes in Python. When I try to print an object of class Foobar using the print() function, I ge

9条回答
  •  春和景丽
    2020-11-21 07:34

    If you're in a situation like @Keith you could try:

    print(a.__dict__)
    

    It goes against what I would consider good style but if you're just trying to debug then it should do what you want.

提交回复
热议问题