Use rstrip
>>> text="Hello\x00\x00\x00\x00"
>>> text.rstrip('\x00')
'Hello'
It removes all \x00
characters at the end of the string.
Use rstrip
>>> text="Hello\x00\x00\x00\x00"
>>> text.rstrip('\x00')
'Hello'
It removes all \x00
characters at the end of the string.