Python中特殊函数__str__()
摘要:
在类中定义了__str__(self)方法,那么当使用print打印实例对象的时候,就会直接打印出在这个方法中return的数据. 案列: 1 class Book: 2 3 def __init__(self, name, author, comment, state = 0): 4 self.n 阅读全文
posted @ 2019-12-30 14:46 Through-Target 阅读(770) 评论(0) 推荐(0) 编辑