“检查类型”是什么意思,为什么需要这样做?

时间:2019-03-22 11:22:03

标签: python python-3.x

我正在网站上练习此问题。它说“向带有参数.add_grade()的Student添加grade方法。 .add_grade()应验证grade的类型为Grade,如果是,请将其添加到Student的{​​{1}}”

有人可以向我解释“检查类型”是什么意思吗?当我在下面的代码中编写代码时,问题没有得到检查,而是弹出一行.grades。我看了一下答案,它显示代码应写为"Does .add_grade() add grade to the instance’s .grades list?"。我不知道为什么

if type(grade) == Grade:

enter image description here

0 个答案:

没有答案
相关问题