只想打印红色和蓝色 -
class color:
def __init__(self,r,b):
self.r = r
self.b = b
def displaycolor(self):
print "The first should be :" self.r
print "The 2nd should be :" self.b
pagal=color("Red","blue")
pagal.displaycolor()
答案 0 :(得分:3)
两个问题:打印时缩进和字符串连接:
class color:
def __init__(self,r,b):
self.r = r
self.b = b
def displaycolor(self):
print "The first should be :", self.r
print "The 2nd should be :", self.b
pagal=color("Red","blue")
pagal.displaycolor()