For marketers
who love technology
Home » » Python: how to solve errors when converting a string (str) to unicode?

Python: how to solve errors when converting a string (str) to unicode?

example of Python language
example of Python language (Photo credit: Wikipedia)
When working with strings in a Python program, if you face errors such as:

TypeError("descriptor 'lower' requires a 'unicode' object but received a 'str'",)

What you are looking for is the instruction below:


unicode(mystr, 'utf-8')

It transcodes your string to the target encoding format.

I hope this post will help you to save time next time you face this error! If yes, please put a comment or a link to this post. Thanks!


SHARE

About Gilles

0 comments :

Post a Comment