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']
Run Code Online (Sandbox Code Playgroud)
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]
Run Code Online (Sandbox Code Playgroud)
You can substitute lstrip for strip if you only care about the characters on the left.
| 归档时间: |
|
| 查看次数: |
623 次 |
| 最近记录: |