Written by
flask-style
on
on
Python : 'str' object has no attribute 'decode' 에러 해결
Python : 'str' object has no attribute 'decode' 에러 해결
로그인 회원가입 기능을 flask에서 구현할 때
error code : 'str' object has no attribute 'decode' 가 나왔다.
문제는 jwt 토큰을 암호화하고 utf-8 로 다시 디코딩해줄 때 나왔는데
token = jwt.encode(payload, SECRET_KEY, algorithm='HS256').decode('utf-8')
검색을 해보니 python3에서는 기본이 utf-8이기 때문에 굳이 decode를 사용할 필요가 없다고 합니다.
따라서 decode 함수도 필요 없습니다.
출처: https://knight76.tistory.com/entry/python2 [김용환 블로그(2004-2020)]
728x90
from http://thalals.tistory.com/165 by ccl(A) rewrite - 2021-10-08 12:26:34