Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I print the raw unicode in python?

I am novice in Python, so maybe I can't express it well...

I got a string '\xb9\xfe'

I want it print in this very fashion '\xb9\xfe', not converting to a Chinese character '哈'.

What is the proper way to do it?

like image 878
novice3 Avatar asked Sep 30 '22 05:09

novice3


1 Answers

Use a raw string literal instead:

r'\xb9\xfe'

or print the output of repr() of your string:

print(repr('\xb9\xfe'))
like image 125
Martijn Pieters Avatar answered Oct 19 '22 19:10

Martijn Pieters