python 断言,round函数

python 断言

>>> assert 1 == 2, 'aaaaaaaaa'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError: aaaaaaaaa

>>>assert isinstance(1, int), 'aaaaaaaaaaaaaa'

round()

>>> round(2, 2)
2.0
>>> round(2.9999, 2)
3.0
>>> round(2.00, 2)
2.0
>>> round(2.12, 2)
2.12
>>> round(2.12111, 2)
2.12
>>> round(2.1111, 2)
2.11

你可能感兴趣的:(python 断言,round函数)