zoukankan      html  css  js  c++  java
  • python--断言

      断言语句和if语句分子有点像,它用于对一个bool表达式进行断言,如果该bool表达式为True,该程序可以向下执行:否则程序会应答AssertionError

     age = int(input())  
      2 assert 20 < age < 80                                               
      3 print("范围在20-80之间")
                        

    运行结果

    45
    范围在20-80之间
    ztr@ztr-G3-3579:~/myself/python/practice$ python3 test_assert.py
    12
    Traceback (most recent call last):
      File "test_assert.py", line 2, in <module>
        assert 20 < age < 80
    AssertionError

    笨鸟先飞
  • 相关阅读:
    个人温度上报小软件
    假期10
    Android开发 07
    假期09
    Android开发 06
    Android开发 05
    假期08
    Android开发 04
    假期07
    每日日报
  • 原文地址:https://www.cnblogs.com/zoutingrong/p/13860393.html
Copyright © 2011-2022 走看看