理解Python中raise、assert语句

    1. Simple statements

    A simple statement is comprised within a single logical line.

    Several simple statements may occur on a single line separated by semicolons.

    The syntax for simple statements is :

    simple_stmt ::= expression_stmt
                    | assert_stmt
                	| assignment_stmt
                    | augmented_assignment_stmt
                    | annotated_assignment_stmt
                    | pass_stmt
                    | del_stmt
                    | return_stmt
                    | yield_stmt
                    | raise_stmt
                    | break_stmt
                    | continue_stmt
                    | import_stmt
                    | future_stmt
                    | global_stmt
                    | nonlocal_stmt
    
  • 7.1 Expression statements
  • 7.2 Assignment statements

    Assignment statements are used to (re)bind names to values to modify attributes or items of mutable objects.

  • 7.3 The assert statement

    Assert statements are a convenient way to insert debugging assertions into a program.

  • 7.4 The pass statement

    pass is a null operation , which means when it is executed, nothing happens.

  • 7.5 The del statement
  • 7.6 The return statement
  • 7.7 The yield statement
  • 7.8 The raise statement

    If no expressions are present, raise re-raise the last exception that was active in the current scope. If no exception is active in the current scope, a RuntimeError exception is raised indicating that this is an error.

    From tutorial, definition of raise is :

    The raise keyword is used to raise an exception. You can define what kind od error to raise, and the text to

  • 7.9 The break statement
  • 7.10 The continue statement
  • 7.11 The import statement
  • 7.12 The global statement
  • 7.13 The nonlocal statement
  • References

  1. Python Tutorial
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值