typeError:can only concatenate str(not"bytes")to str

배경:프로젝트 Python 2.7 을 Python 3.8 로,Django 1.10 을 Django 3.0 으로 업그레이드
python 3.4 이후 유 니 코드(value,utf-8)를 직접 사용 할 수 없 기 때 문 입 니 다.
그래서 코드
data = '{"id":"' + location_key_id + '","location_name": "' + unicode(location_name, 'utf-8') + '","leaf:"'+true+'"}'

삭제 가 필요 하면 바로:
data = '{"id":"' + location_key_id + '","location_name": "' + location_name + '","leaf:"'+true+'"}'

호출 코드 가 잘못 되 었 습 니 다.
can only concatenate str (not "bytes") to str

다음으로 변경:
data = '{"id":"' + location_key_id + '","location_name": "' + str(location_name) + '","leaf:"'+true+'"}'

문제 해결!!

좋은 웹페이지 즐겨찾기