# -*- coding:utf-8 -*- from base64 import * flag = open("code.txt").readline() # 读取密文 for i in range(10): pointer = 0 try: temp = b16decode(flag) except TypeError: pointer = 1 # 指示是否发生TypeError异常 if pointer == 1 or '�' in temp: # 如果解码方式不对,就会提示TypeError,或者乱码,发现乱码中必有'�' pointer = 0 try: temp = b32decode(flag) except TypeError: pointer = 1 if pointer == 1 or '�' in temp: temp = b64decode(flag) flag = temp print flag