About 132,000 results
Open links in new tab
  1. python - What is a unicode string? - Stack Overflow

    Feb 16, 2014 · The line ustring = u'A unicode \u018e string \xf1' creates a Unicode string with 20 characters. When the Python interpreter displays the value of ustring, it escapes two of the …

  2. How to print Unicode character in Python? - Stack Overflow

    Dec 7, 2013 · To include Unicode characters in your Python source code, you can use Unicode escape characters in the form \u0123 in your string. In Python 2.x, you also need to prefix the …

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

    What before was valid UTF-8, isn't anymore. Using a unicode string you cannot operate in such a way that the resulting string isn't valid unicode text. You can remove a code point, replace a …

  4. Convert a Unicode string to a string in Python (containing extra ...

    May 24, 2023 · In Python 3, this form of file access is the default, and the built-in open function will take an encoding parameter and always translate to/from Unicode strings (the default …

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

    Apr 24, 2012 · Python byte strings (str type) have an encoding, Unicode does not. You can convert a Unicode string to a Python byte string using uni.encode(encoding), and you can …

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

    In a Python 2 program that I used for many years there was this line: ocd[i].namn=unicode(a[:b], 'utf-8') This did not work in Python 3. However, the program turned out to work with: …

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

    Oct 19, 2021 · It's been the syntax since Python 2.0. 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 …

  8. How can I compare a unicode type to a string in python?

    May 10, 2013 · A UTF-8 string on the other hand, is a sequence encoded bytes. You may want to read up on Unicode and Python to understand the difference: The Absolute Minimum Every …

  9. How do I convert a unicode to a string at the Python level?

    If you have u'Andr\xc3\xa9', that is a Unicode string that was decoded from a byte string with the wrong encoding. The correct encoding is UTF-8. To convert it back to a byte string so you can …

  10. How to convert a string to utf-8 in Python - Stack Overflow

    May 3, 2018 · It is not what OP asks. But avoid such string literals anyway. It creates Unicode string in Python 3 (good) but it is a bytestring in Python 2 (bad). Either add from __future__ …