Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当我运行代码时,我得到:AttributeError:';CD&x27;对象没有属性'_CD_uuid';_Python - Fatal编程技术网

Python 当我运行代码时,我得到:AttributeError:';CD&x27;对象没有属性'_CD_uuid';

Python 当我运行代码时,我得到:AttributeError:';CD&x27;对象没有属性'_CD_uuid';,python,Python,这是我的代码: class Product: def __init__(self,id, title, price): self.__id = id self. __title = title self. __price = price def get_id_title_price(self): return "ID: "+str(self.__id)+" Title:&quo

这是我的代码:

class Product:
    
    def __init__(self,id, title, price):
        self.__id = id
        self. __title = title
        self. __price = price
    def get_id_title_price(self):
        return "ID: "+str(self.__id)+" Title:"+self.__title+ "Price: "+str(self.__price)

#write your code here
class Book(Product):
    def __init__(self,id, title, price, isbn, publisher):
        super().__init__(id, title, price)
        self.isbn = isbn
        self.publisher = publisher
    def printDetail(self):
        return f"{super().get_id_title_price()}\nISBN: {self.isbn} Publisher: {self.publisher}"

class CD(Product):
    def __init__(self, id, title, price, band, duration, genre):
        super().__init__(id, title, price)
        self.band = band
        self.genre = genre
        self.duration = duration
    def printDetail(self):
        return "ID: "+str(self.__id)+" Title:"+self.__title+ " Shotto Price: "+str(self.__price) + "Band: "+ self.band + "Duration: "+str(self.duration)+ "Genre: "+ self.genre

book = Book(1,"The Alchemist",500,"97806","HarperCollins")
print(book.printDetail())
print("-----------------------")
cd = CD(2,"Shotto",300,"Warfaze",50,"Hard Rock")
print(cd.printDetail()) 
当我运行它时,会出现以下错误:

AttributeError:“CD”对象没有属性“\u CD\u id”

但是我找不到我在哪里犯的错误

见:和