repr

    [파이썬] str과 repr

    __str__ str(), format(), print()에 의해 호출되어 객체의 인쇄 가능한 비형식적(informal) 문자열 표현을 반환한다. __repr__ repr()에 의해 호출되어 객체의 공식적(formal)인 문자열 표현을 반환한다. 개체를 다시 만드는 데 사용할 수 있는 유효한 파이썬 표현을 만든다. class Ex: pass b = Ex() print(repr(b)) # 따로 형태가 정의되지 않으면 클래스 이름과 변수가 있는 메모리 주소를 기본형으로 출력한다. (By default, it prints the module the object it's from, the class name, and the hexadecimal representation of its location in mem..