String splitting in python by finding non-zero character -
i want following split:
input: 0x0000007c9226fc output: 7c9226fc input: 0x000000007c90e8ab output: 7c90e8ab input: 0x000000007c9220fc output: 7c9220fc
i use following line of code not work!
split = element.rpartition('0')
i got these outputs wrong!
input: 0x000000007c90e8ab output: e8ab input: 0x000000007c9220fc output: fc
what fastest way kind of split? idea me right make loop , perform checking little time consuming.
i should mention number of zeros in input not fixed.
each string can converted integer using int()
base of 16. convert string.
for s in '0x000000007c9226fc', '0x000000007c90e8ab', '0x000000007c9220fc': print '%x' % int(s, 16)
output
7c9226fc 7c90e8ab 7c9220fc
Comments
Post a Comment