我用pyDes编码了一个char'a',我想对其进行解码
text = self.textbuffer.get_text(start, end)
print text
//',\xcc\x08\xe5\xa1\xa1fc'
x = "{}".format(text)
print x
//',\xcc\x08\xe5\xa1\xa1fc'
but i need
//,塡fc
当我做
cipher_text = ',\xcc\x08\xe5\xa1\xa1fc'
print cipher_text
//,塡fc
为什么
text = self.textbuffer.get_text(start, end)
didn't return me a good string ?
您的解决方案在这里不起作用,但我取得了进展:
text = self.textbuffer.get_text(start, end)
a = text.decode('unicode-escape')
g = a.encode('utf-16be')
这几乎是很好,但是当我这样做时
print g
//',���fc'
print "%r"%g
//"\x00'\x00,\x00\xcc\x00\x08\x00\xe5\x00\xa1\x00\xa1\x00f\x00c\x00'"
现在我在如何删除所有\ x00上遇到了问题
newstr = g.replace("\x00", "")
newstr2 = newstr.replace("'", "")
newstr2这是一个不好的解决方案,它仅适用于小字符串
www说
相关分类