본문 바로가기
기록/Python

[Python] TypeError: unsupported operand type(s)

by 자임 2022. 6. 21.

유효기간 만료 체크해주는 부분에서 TypeError: unsupported operand type(s) 오류남.

 

원인 : 파이썬의 기본연산이 불가능한 타입끼리 연산을 하려고 할 때 발생 (예를 들어 문자열과 숫자는 당연히 연산 불가..)

 

 

refresh_token_expire > checkExpire

 

refresh_token_expire = tokens['refresh_token_expire']
refresh_token_expire = refresh_token_expire[0:10]

nowTime = datetime.date.today()
checkExpire = str(nowTime + datetime.timedelta(days=1))

 

refresh token이 datetime으로 저장돼서 해당 타입일 거라고 생각했는데, 파일에 저장된 값을 불러오는 거라 str 타입이었다..ㅎㅎ.. 

 

초보자의 실수. 현재 날짜를 str로 변환해주니까 오류 사라짐.

 

 

 

참고 : https://daewonyoon.tistory.com/385

 

[Python] TypeError: unsupported operand type(s) for

파이썬 초보가 겪을 수 있는 에러입니다. unsupported operand type : 지원되지 않는 피연산자 타입 으로 번역이 됩니다. 파이썬의 기본연산이 불가능한 타입끼리 연산을 하려고 할 때 발생합니다. 예를

daewonyoon.tistory.com