Reputation: 2169
How would I print '\x08' as '\x08' in python? If I enter the command
print '\x08'
the output is blank instead of
\x08
Upvotes: 3
Views: 8204
Reputation: 889
In general, you can also do print repr(c).strip("'")
, where c is the string you want to view in the code format, ie TAB will show as '\t' and newline as '\n' and so on..
Upvotes: 0
Reputation: 3214
Please use r
before string, it means raw string, in which you don't need to escape special chars. For more details about string literal prefixes please read the documentation.
print r'\x08'
Upvotes: 9
Reputation: 26397
You can just escape '\x08'
(backspace character) by doing,
print '\\x08'
Upvotes: 1