if wb == 'Encode a sentence' or wb == 'encode a sentence':
print("Please enter the Sentence...")
str = input()
str = str.encode('base64','strict')
print(str)
它告訴我,它不能是字節,它們應該是字符串...任何幫助表示讚賞!我無法編碼我的輸入
if wb == 'Encode a sentence' or wb == 'encode a sentence':
print("Please enter the Sentence...")
str = input()
str = str.encode('base64','strict')
print(str)
它告訴我,它不能是字節,它們應該是字符串...任何幫助表示讚賞!我無法編碼我的輸入
試試這個:
from base64 import b64encode
b64encode(wb.encode())
也爲你如果線路使用
if wb.lower() == 'encode a sentence':
謝謝!很多我的朋友 –
你可以試試這個:
import base64
if wb == 'Encode a sentence' or wb == 'encode a sentence':
print("Please enter the Sentence...")
str = input()
base64.b64encode(bytes(str, 'utf-8'))
print(str)
您正在使用什麼版本的Python? –
Im using python 3.5.0 –
在附註中,最好使用不同的變量名稱而不是'str',因爲這是一個Python內置的函數,可用於諸如'str.encode('my字符串')' –