我想base64encode(ntei)
在“Heres the number in base 64:”下换一个新行,有人知道方法吗?
import easygui as e
nte = e.enterbox(msg="Enter Number to convert", title="", default="", strip=True)
ntei = int(nte)
def base64encode(number, alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"):
"""Converts an integer to a base64 string."""
if not isinstance(number, (int, long)):
raise TypeError("Number must be an integer")
base64 = ""
sign = ""
if number < 0:
sign = "_"
number = -number
if 0 <= number <len(alphabet):
return sign + alphabet[number]
while number !=0:
number, i = divmod(number, len(alphabet))
base64 = alphabet[i] + base64
return sign + base64
def base60decode(number):
return int(number, 64)
print e.msgbox(msg=("Heres the number in base 64: " + base64encode(ntei)))