第41697题 单选题
下面的代码在主程序 if __name__ == "__main__": 中有没有一行会导致运行错误,如果有请找出错误行 ()
class Pet:
    def __init__(self, n, a):
        self._name = n
        self._age = a
    def get_name(self):
        return self._name
    def birthday(self):
        self._age += 1

if __name__ == "__main__":
    cat = Pet("奶茶", 2)
    print(cat.get_name()) # ①
    cat.birthday() # ②
    cat._name = "大橘" # ③
    print(cat.get_name()) # ④
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析