Knowledge Map

python3 bytes class => json 본문

PYTHON

python3 bytes class => json

2018. 1. 16. 18:02

https://stackoverflow.com/questions/6539881/python-converting-from-iso-8859-1-latin1-to-utf-8

python3에서 바이트 값은 json.dumps를 할 경우 에러가 발생한다.
물론 문자열로 변환하면 되지만 그렇게 될 경우 손실이 발생되어 이후 처리에서 제대로 되지 않을 가능성이 존재한다.

이럴때 decode('iso-8859-1') 로 하게 되면 바이트를 손실없이 문자열로 변환할 수 있으니 좋다.


Comments