【发布时间】:2020-05-25 17:34:16
【问题描述】:
我在__init__ 方法上编写了一个带有三个参数的类Question。但是当我尝试打印属性时,代码会引发属性错误。
class Question:
def __init__(self, question, ca, cb, cc, cd, correct_choice):
self.__question = question
self.__choice_a = ca
self.__choice_b = cb
self.__choice_c = cc
self.__choice_d = cd
self.__correct = correct_choice
# Create instances
q1 = Question(
'What is the square root of 622521?',
789, 790, 791, 792,
'a'
)
**print(q1.__choice_d)** # This part of the code raises an attribute error.
【问题讨论】: