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!


Leave a Reply

Your email address will not be published. Required fields are marked *