How do I disable assertions in Python? There are multiple approaches that affect a single process, the environment, or a single line of code. I demonstrate each. For the whole process Using the -O flag (capital O) disables all assert statements in a…
Python assert(断言)可以分别后面的判断是否正确,如果错误会报错 示例: a = 1 assert type(a) is int print('No problem') 输出结果: No problem a = ' assert type(a) is int print('No problem') 输出结果: Traceback (most recent call last): File "D:/test.py", line 3, in <module> …