我想做以下拆分:
input: 0x0000007c9226fc output: 7c9226fc
input: 0x000000007c90e8ab output: 7c90e8ab
input: 0x000000007c9220fc output: 7c9220fc
Run Code Online (Sandbox Code Playgroud)
我使用以下代码行来执行此操作但它不起作用!
split = element.rpartition('0')
Run Code Online (Sandbox Code Playgroud)
我得到了这些错误的输出!
input: 0x000000007c90e8ab output: e8ab
input: 0x000000007c9220fc output: fc
Run Code Online (Sandbox Code Playgroud)
做这种分裂的最快方法是什么?我现在唯一的想法是制作一个循环并执行检查,但这有点耗费时间.
我应该提一下输入中的零个数是不固定的.
可以使用int()16的基数将每个字符串转换为整数.然后转换回字符串.
for s in '0x000000007c9226fc', '0x000000007c90e8ab', '0x000000007c9220fc':
print '%x' % int(s, 16)
Run Code Online (Sandbox Code Playgroud)
产量
7c9226fc 7c90e8ab 7c9220fc
| 归档时间: |
|
| 查看次数: |
704 次 |
| 最近记录: |