How to decode character to utf-8 at specific position

I have a python script, in which there is a dictionary. For some reason, I need to convert dictionary to json. But, whenever script executed, It gives below error

UnicodeDecodeError: 'utf8' codec can't decode byte 0xe9 in position 604: invalid continuation byte

for line json.dumps(data_dict).

From link, I understand that non utf character should be decoded. But how to do it in a script? How we can get character at that positon from dictionary and decode it.

On interpreter, it works. Below is interpreter snippet.




You're attempting to decode an invalid UTF-8 codepoint. Non-UTF-8 characters cannot be decoded. Try passing 'ignore' to .decode if you absolutely must handle invalid codepoints, or try the chardet library to detect the actual encoding (.decode will encode into Unicode).

Category: centos Time: 2016-07-28 Views: 1

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development


Front-end development


development tools

Open Platform

Javascript development

.NET development

cloud computing


Copyright (C), All Rights Reserved.

processed in 0.262 (s). 12 q(s)