class Point4D(object):
def __init__(self,w, x, y, z):
self.w = w
self.x = x
self.y = y
self.z = z
def __str__(self):
print('{}, {}, {}, {}'.format(self.w, self.x, self.y, self.z))
my_4d_point = Point4D(1, 2, 3, 1)
print(my_4d_point)
我得到输出 1 2 3 1 ,但我不断收到错误
TypeError: __str__ returned non-string (type NoneType) in line 12.
为什么?