本文介绍了python十六进制字符串中0x和\ x的含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在执行一些二进制操作,这些操作通常显示为hex-es.我已经将0x
和\x
都视为前缀.
I'm doing some binary operations which are often shown as hex-es. I have seen both the 0x
and \x
as prefixes.
在哪种情况下使用?
推荐答案
0x
用于文字数字. "\x"
用于在字符串内部表示字符
0x
is used for literal numbers. "\x"
is used inside strings to represent a character
>>> 0x41
65
>>> "\x41"
'A'
>>> "\x01" # a non printable character
'\x01'
这篇关于python十六进制字符串中0x和\ x的含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!