Python中不盡如人意的斷言Assertion

Python Assert 爲何不盡如人意 Python中的斷言用起來非常簡單,你可以在assert後面跟上任意判斷條件,如果斷言失敗則會拋出異常。 >>> assert 1 + 1 == 2 >>> assert isinstance('Hello', str) >>> assert isinstance('Hello', int) Traceback (most recent call la
相關文章
相關標籤/搜索