try
:
print
(name)
except
Exception as e:
print
(
type
(e),e
print
(
"gtq"
)
gtqDict={"Name":"光头强","Age":34,"Gender":"男"
try:
print(gtqDict["Weight"])
except KeyError:
print("Weight不存在,继续走"
print(gtqDict["Age"])
print(gtqDict["Gender"])
https://www.jb51.net/article/164035.htm