1 def jiecheng(num,zhishu): 2 """ 3 求一个数的幂指数 4 :param num: 5 :param zhi: 6 :return: 7 """ 8 print('结果是:') 9 restult = num ** zhi 10 return restult 11 12 while 1: 13 num = input('一个数(输入q退出程序):') 14 if num.lower() =='q': 15 break 16 else: 17 num = int(num) 18 zhi = int(input('请输入这个数的指数:')) 19 res = jiecheng(num,zhishu) 20 print('最后的结果是:'+ str(res))