gpt4 book ai didi

python - "__str__ returned non-string"错误,但显示输出

转载 作者:太空宇宙 更新时间:2023-11-04 10:39:03 25 4
gpt4 key购买 nike

<分区>

在我的课上我有

def __str__(self):
print "abc"

当我创建这个类的对象a 并键入print a 时,它会打印abc(正确),但随后也会给出输出

Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
print a
TypeError: __str__ returned non-string (type NoneType)

我该如何解决?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com