myString = 'éíěřáé'
I need to decode this string to unicode.
Is there any difference between folowing usages and between these two methods in general?
myString.decode(encoding='UTF-8', errors='ignore')
and
unicode(myString, encoding='UTF-8', errors='ignore')
The
unicodeconstructor can take other types apart from strings:For the bytestring case, however, the two forms are mostly equivalent. Some encoding options are not valid for the
unicodeconstructor as they do not result in unicode output, but are valid for the.decodemethod of bytestrings, such as'hex':