1

In python, what is the escape sequence for the left-double quote Unicode character (U+201C)?

left_double_quote = "“"

print(ord(left_double_quote)) # prints `8220`

Note that 201C is hexadecimal notation for the decimal number 8220

I tried somethings, but it did not work:

print("\x8220")
print("\x201C")
print("\0x201C")
Toothpick Anemone
  • 4,290
  • 2
  • 20
  • 42
  • 1
    In this specific case, `print("\u201C")`. It cannot use `\x` because that only accommodates two hex digits. Please see the linked duplicate for details. – Karl Knechtel Apr 28 '23 at 02:10

1 Answers1

1

You can use the \u escape to indicate you are specifying unicode bytes rather than hex (ASCII?) bytes.

So for your example, you can use this:

print("\u201c")

# output: “
Matthias Fripp
  • 17,670
  • 5
  • 28
  • 45