About 5,690,000 results
Open links in new tab
  1. How to print Unicode character in Python? - Stack Overflow

    May 13, 2012 · In Python 2, you declare unicode strings with a u, as in u"猫" and use decode() and encode() to translate to and from unicode, respectively. It's quite a bit easier in Python 3.

  2. Usage of unicode () and encode () functions in Python

    Apr 24, 2012 · 135 str is text representation in bytes, unicode is text representation in characters. You decode text from bytes to unicode and encode a unicode into bytes with some encoding. …

  3. What's the u prefix in a Python string? - Stack Overflow

    Python 3 made them redundant, as the default string type is Unicode. Versions 3.0 through 3.2 removed them, but they were re-added in 3.3+ for compatibility with Python 2 to aide the 2 to 3 …

  4. Unicode (UTF-8) reading and writing to files in Python

    This particular reading allows one to take UTF-8 representations from within Python, copy them into an ASCII file, and have them be read in to Unicode. Under the "string-escape" decode, the …

  5. Why declare unicode by string in python? - Stack Overflow

    For the Unicode string, Python read \x81, knew that in cp437 that was a ü, and decoded it into the Unicode codepoint for ü which is U+00FC. When the byte string was printed, Python sent the …

  6. python - What is a unicode string? - Stack Overflow

    Feb 16, 2014 · In Python 3, Unicode strings are the default. The type str is a collection of Unicode code points, and the type bytes is used for representing collections of 8-bit integers (often …

  7. unicode - How to make the python interpreter correctly handle …

    Aug 27, 2009 · Python 2 uses ascii as the default encoding for source files, which means you must specify another encoding at the top of the file to use non-ascii unicode characters in literals.

  8. python - How to make unicode string with python3 - Stack Overflow

    Literal strings are unicode by default in Python3. Assuming that text is a bytes object, just use text.decode('utf-8') unicode of Python2 is equivalent to str in Python3, so you can also write:

  9. python - Error " (unicode error) 'unicodeescape' codec can't …

    May 24, 2016 · I get the following error: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape I have tried to replace the \ with …

  10. string - Python str vs unicode types - Stack Overflow

    Working with Python 2.7, I'm wondering what real advantage there is in using the type unicode instead of str, as both of them seem to be able to hold Unicode strings. Is there any special …