Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/300.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
0x%4x在python中是什么意思?_Python_Python 2.7 - Fatal编程技术网

0x%4x在python中是什么意思?

0x%4x在python中是什么意思?,python,python-2.7,Python,Python 2.7,我想我理解%在python中的含义。但我不明白0x和4x是什么意思。即使您只是链接了%的文档,任何帮助都是非常好的 下面是示例代码: wr.write('Base Addr=0x%4x' % (Base_Address)) %4x是在十六进制中格式化数字的一种方法 >>> '%4x' % 0xffff 'ffff' >>> '%4x' % 0xffa1 'ffa1' 前导的0x将只是文字字符,最终会带入字符串中 >>&g

我想我理解%在python中的含义。但我不明白0x和4x是什么意思。即使您只是链接了%的文档,任何帮助都是非常好的

下面是示例代码:

wr.write('Base Addr=0x%4x' % 
           (Base_Address))

%4x
是在十六进制中格式化数字的一种方法

>>> '%4x' % 0xffff
'ffff'
>>> '%4x' % 0xffa1
'ffa1'
前导的
0x
将只是文字字符,最终会带入字符串中

>>> '0x%4x' % 0xffa1
'0xffa1'
4
指定最小宽度(较小的输出将在左侧用空格填充):


%4x
是在十六进制中格式化数字的一种方法

>>> '%4x' % 0xffff
'ffff'
>>> '%4x' % 0xffa1
'ffa1'
前导的
0x
将只是文字字符,最终会带入字符串中

>>> '0x%4x' % 0xffa1
'0xffa1'
4
指定最小宽度(较小的输出将在左侧用空格填充):


非常感谢。我现在明白了!非常感谢。我现在明白了!我找不到我找不到