-4

只是想打印红色和蓝色-

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()
4

1 回答 1

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()
于 2013-09-25T11:05:40.227 回答