代码示例:(标识:demo_python_ref_keyword_assert_1)
demo_python_ref_keyword_assert_1.py
x = "hello"

#if condition returns True, then nothing happens:
assert x == "hello"

#if condition returns False, AssertionError is raised:
assert x == "goodbye"
运行结果: