import requests import jsonimport pymysqlcode = input("请输入id:") #print(code) code1 = (repr(code)) #print(code1) #通过调接口生成加密后code url = "http://XXX/generateId"params = {"List": code} headers = {'content-type': "application/json", "Label": "S"} r = requests.post(url, data=json.dumps(params), headers=headers)#print(r.text)#获取上个步骤的加密code connection = pymysql.connect(host="base", user="A", password="V", db="C", port=3306, charset='utf8') cur = connection.cursor()sql = "select crypt from C t where t.code = %s" %(code1) #print(sql) try:cur.execute(sql)result = cur.fetchall()except:print('Error:unable to fetch data')#print(result) cryptcode = result[0] #print(cryptcode) results = "https://XXX&Id=%s"%(code)+"&Idcrypt=%s"%(cryptcode) print("ID二维码生成链接:%s \n"%(results))connection.close() input('press enter to exit!')