[英]a bytes-like object is required, not 'str' error in python
我正在寫代碼
image = Image.open(filename) #opening the image
binary = bin(int(binascii.hexlify(message), 16)) #converting string into binary
binary = binary.append('1111111111111110') #adding delimeter at the end
binary = binary**.lstrip('0b') #removing the starting ob of binary
............繼續
由於第 2 行,我收到此錯誤
**二進制 = bin(int(binascii.hexlify(message), 16))
TypeError:需要類似字節的 object,而不是“str”
我不明白這個錯誤,似乎沒有任何工作
變量message
包含一個字符串,但它需要是一個字節序列。 要將字符串編碼為字節,您可以執行以下操作:
message.encode('utf-8')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.