type(object)
이 사용자 지정 문자열을보고하도록 CLASS OBJECT를 변경하는 방법이 있습니까?'type()'보고서를 재정의하는 방법
class MyClass(object):
def __init__(self, t):
if 'detector' in t:
my_type_string = "I am set as a detector."
else:
my_type_string = "I am set as a broadcaster."
>>> o = MyClass('detector')
>>> type(o)
I am set as a detector.
'형식을 반환 할 수 있기 때문에 (..)'** 문자열을 반환하지 않습니다 ... –