python `

    技术2022-07-10  141

    https://docs.python.org/3/reference/datamodel.html#object.str object.__str__(self) 该方法是为了输出对象的基本信息,在print(object)的时候展示

    In [1]: class student: ...: def __str__(self): ...: msg="这是一个测试" ...: return msg # 注意一定要有返回值 In [2]: student_a=student() In [3]: print(student_a) 这是一个测试
    Processed: 0.011, SQL: 12