We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
while True: try: x = int(input('请输入x:')) y = int(input('请输入y:')) value = x / y print('x / y is',value) except Exception as e: # 发生异常时执行 print('不正确的输入:',e) print('请重新输入') else: # 未发生异常时执行 break
try…except…else语句中的except子句中的代码会在发生异常时执行,而else子句中的代码会在try…except之间的代码正常执行完后执行,也就是当代码执行正确时执行。
try…except…else
except
else
try…except
The text was updated successfully, but these errors were encountered:
No branches or pull requests
try…except…else
语句中的except
子句中的代码会在发生异常时执行,而else
子句中的代码会在try…except
之间的代码正常执行完后执行,也就是当代码执行正确时执行。The text was updated successfully, but these errors were encountered: