class Restaurant():
def _int_(self,restaurant_name,restaurant_type):
self.restaurant_name=restaurant_name
self.restaurant_type=restaurant_type
my_restaurant=("dangao","yuebing")
print("\n你的餐館的名字"+my_restaurant.name+"菜品型別"+my_restaurant.type)
錯誤型別:print("\n你的餐館的名字"+my_restaurant.name+"菜品型別"+my_restaurant.type)
AttributeError: 'tuple' object has no attribute 'name'
uj5u.com熱心網友回復:
都是些啥呀, 想要做啥?從哪里抄的代碼?敲代碼的時候,要認真看書上的代碼,不要買盜版書。
class Restaurant:
def __init__(self,restaurant_name,restaurant_type):
self.name=restaurant_name
self.type=restaurant_type
my_restaurant=Restaurant("dangao","yuebing")
print("\n你的餐館的名字"+my_restaurant.name+"菜品型別"+my_restaurant.type)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/144303.html
下一篇:python中字串去重問題
