如何去除文末不可见字符
解密文件后,文末多了一些16进制下是0x0的字符,文本下查看显示的是^@,若干个,如何去除呢,可能是加密时为了凑长度添加的。
试过strip(),和strip(' '),无效,
回复 1# henry_wu001
I got it.
>>> s = "some\x00string. with\x15 funny characters"
>>> import string
>>> filter(lambda x: x in string.printable, s)
'somestring. with funny characters'
refs:
http://stackoverflow.com/questions/8689795/python-remove-non-ascii-characters-but-leave-periods-and-spaces
页:
[1]