TypeError: __str__ returned non-string (type NoneType)

    def __str__(self):
        return print("这个地瓜被烤的时间是{},状态是{}".format(self.cook_time, self.cook_state))

Return:
Insert picture description here
ie: "Type error: returned non-string type"

In the return statement, correct the following to execute normally

    def __str__(self):
        return "这个地瓜被烤的时间是{},状态是{}".format(self.cook_time, self.cook_state)

In the __str__() method, write the content to be returned directly after return.

Guess you like

Origin blog.csdn.net/weixin_47008635/article/details/114606640