在线名词解释大全
专业、全面、易懂的全领域名词百科

7()Analyzethefollowingcode:classA:def__init__(self,s):self.s=sdefprint(self):print(s)a=A("Welcome")a.print()

题型:单选题
选项
A. The program has an error because class A does not have a constructor.
B. The program has an error because class A should have a print method with signature print(self, s).
C. The program has an error because class A should have a print method with signature print(s).
D. The program would run if you change print(s) to print(self.s).
正确答案:D