Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
def make(key): key = base64.b64decode(key)
当我运行这个函数时,我在这一行得到一个类型错误。
这是怎么回事?
心理调试:您可能str向函数传递了一个对象,但base64.b64decode需要一个bytes对象。因此,您需要对字符串进行编码。
str
base64.b64decode
bytes
key = base64.b64decode(key.encode('ASCII'))
请注意,Python 3.3更宽松,允许您通过str或bytes。