carte blanche
carte blanche

Reputation: 11486

deleting \x00 in front of a number in list

I have a list as follows,how to delete the junk '\x00\x00.. in front of 563015

['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00563015', '553261', '541526']

Upvotes: 2

Views: 656

Answers (1)

Mark Ransom
Mark Ransom

Reputation: 308452

You have a list of strings, strip is used to remove characters from either end of a string.

a = [ #... ]
b = [s.strip('\x00') for s in a]

You can substitute lstrip for strip if you only care about the characters on the left.

Upvotes: 5

Related Questions