python - 为什么“try...else”在 Python 中是“无效语法”?
问题描述
普通的:
try:
something may go wrong...
except:
pass
else:
others func...
我需要的:
try:
something may go wrong...
else:
others func...
'try...else' 不存在有什么原因吗?
解决方案
如果支持,语法
try:
something may go wrong...
else:
others func...
在行为上完全等同于
something may go wrong...
others func...
即你不需要任何特殊的语法
推荐阅读
- flask - 将 Flask 与 Faust 集成
- amazon-redshift - Redshift - 用撇号过滤文本
- python - 如何编写新的 csv 文件作为另一个文件的扩展名?
- php - 更新多行Mysql PHP需要很长时间并且崩溃
- visual-studio-code - 使 VS Code 解析并显示一种新语言的结构到 VSC 的轮廓区域
- timer - 如何在特定时间内显示小部件?
- python-3.x - 从类/对象文件打印属性
- c# - 使用 SAP Webservices 时阵列不工作
- python - 将具有多个标头的 DataFrame 融合为规范化格式
- ios - 如何在 iOS Swift 中正确恢复应用内购买产品