import random print("*"*71) print("*"*27+"欢迎来到名人猜猜猜"+"*"*27) print("*"*29+"Let's begining"+"*"*28) character_1='他是巨星' character_2='他是篮球健将' character_3='他身高超过2米' character_4='他爱国' character_5='他是北京申办冬奥会形象大使之一' character_6='他是NBA球星麦迪的队友' character_7='他喜欢做慈善' character_8='他是上海人' character_9='汶川地震他捐款1600万' character_10='他是中国人' the_man='姚明' characters=['character_1','character_2','character_3','character_4', 'character_5','character_6','character_7','character_8', 'character_9','character_10'] def random_Int(start,end): return random.randint(start,end-1) length=len(characters) count=0 while len(characters)>0: count=count+1 index=random_Int(0,len(characters)) print("请输入特性%d" %count,eval(characters[index])) guess_name=input("请输入猜测的人名:") if guess_name==the_man: print("您猜对了") break else: characters.pop(index) if count==10: print("您猜错了十次") break else: print("请继续猜")标签:count,index,函数,Python,random,character,实例,characters,print From: https://www.cnblogs.com/longlyseul/p/18115869