[英]how to store bytes like b'PK\x03\x04\x14\x00\x08\x08\x08\x009bwR\x00\x00\x00\x00\x00\x00\x00 to dataframe or csv in python
[英]python how to convert Special string u'\x08' u'\x09' u'\x03' to 8 9 3
在Go中使用加密加密字符串。
PKCS7填充密文,因為密文必須是塊大小(16)的倍數。
exa: ciphertext is : 123456789abcde. (len:14)
pandding: []byte("123456789abcdef") + []byte(2) + []byte(2)
Python解碼:
list: [u'1', u'2', u'3', ...,u'd', u'e', u'\x02', u'\x02']
現在,無法將u'\\ x02'設置為數字2。
我敢肯定這不是在python中執行此操作的最佳方法,但我傾向於在C語言中進行思考,因此請繼續。 對大多數人來說,這可能是很糟糕的,但它可以完成工作。
c = u'\x02'
byte = bytearray(c, 'utf-8')[0]
print(chr(ord('0') + byte))
=> 2
受到安達斯的啟發
c = ord(u'\x02') + ord('0')
print chr(c)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.