📜  检查变量是否已定义 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:40.088000             🧑  作者: Mango

代码示例2
try:
    thevariable
except NameError:
    print("well, it WASN'T defined after all!")
else:
    print("sure, it was defined.")