while True: score = input("输入分数:") try: score = int(score.strip()) if not (0 <= score <= 100): raise ValueError('分数必须0-100之间') break except ValueError as e: print('输入有误,请重试') if 80 <= score <= 100: print('优秀') elif 70 <= score < 80: print('良好') elif 60 <= score < 70: print('合格') else: print('不合格')