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 これは悪い解決策です。小さな文字列に対してのみ機能します