简体   繁体   中英

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?

Use a raw string literal instead:

r'\xb9\xfe'

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

print(repr('\xb9\xfe'))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM