python的base64编码代码实现
python的base64编码代码实现(学习记录) base64_list = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'] def encode_ascii(string: str) -> str: temp = '' base = '' # 把原始字符串转换为二进制,用bin转换后去掉开头的0b,首位补0补齐8位 for i in string: temp += '{:08}'.format(int(str(bin(ord(i))).replace('0b', ''))) # 6位一组截取,最后一组不足6位的后面补0,获取base_list中对应的字符 for j in range(0,