__repr____str__ 의 차이:

class A:
	def __str__(self):
		return 'this is string'
 
	def __repr__(self):
		return 'this is representation'
 
>> a = A()
>> str(a) # 1
>> a # 2
>> print(a) # 3
 
# 1 -> 'this is string'
# 2 -> this is representation
# 3 -> this is string
 
 

str은 서로 다른 자료형 간에 인터페이스를 제공한다 repr는 사람이 객체를 이해할 수 있도록 표현한다


참고자료: