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字符串')' –