Reputation: 11486
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
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