简单的异常处理
# 简单的异常处理
# 代码
try:
text = input('Enter someting -->')
except EOFError: # 按ctrl+D
print('Why did you do an EOF on me?')
except KeyboardInterrupt: # 按ctrl+C
print('You cancelled the operation.')
else:
print('You enterd {}'.format(text))
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# 运行结果
Enter someting -->^D
Why did you do an EOF on me?
1
2
2
1
2
2
编辑 (opens new window)
上次更新: 2022/12/31, 16:52:27
- 01
- SpringCache基本配置类05-16
- 03
- Rpamis-security-原理解析12-13