Like previous post, the UnicodeDecodeError may occur in the following code:
The problem is caused by data contains some non-ascii data, and the default encoding kid choose for decoding is ascii. Actually kid has an attributing assme_encoding, are used to converting data to unicode.
import kid t_mod = kid.load_template(template_file t_class = t_mod.Template t_class.serializer = kid.HTMLSerializer() t = t_class(**data) return t.serialize(output='html')
The problem is caused by data contains some non-ascii data, and the default encoding kid choose for decoding is ascii. Actually kid has an attributing assme_encoding, are used to converting data to unicode.
import kid t_mod = kid.load_template(template_file t_class = t_mod.Template t_class.serializer = kid.HTMLSerializer() t = t_class(**data) t.assume_encoding = 'utf-8' return t.serialize(output='html')
Comments