try except 异常检测语句


Python 编程语言中的 try except 语句,用于检测并抛出异常。

要赋值的关键词名称,若包括 - 字符则会弹出 SyntaxError: cannot assign to operator

try:
    example-name = "test"
except SyntaxError:
    pass
					
try:
    example-name = "test"
except SyntaxError as reasoned:
    print(reasoned)
					
try:
    example-name = "test"
except:
    pass
					

See also:

Copyright Notice: This article is exclusive original manuscripts, copyrighted by Happy Digits Software , shall not be reproduced without permission.

Previous topic

try except Statement

Next topic

try except Statement

Quick search