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

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