请求各位大神的帮助,我在做class这一章的练习时,遇到报错,不知道如何修改,题目是要输出用户信息以及问候语,出现报错后,我有三个疑惑点:1、tuple指的是程序中的哪一部分;2、为什么会出现识别为tuple的情况;3、如何纠正这个错误 求各位老师的指点,感恩! # 9-3 users class User: """record users' attributes""" def __init__(self,first_name,last_name,age,gender): """initialize attributes to describe a user""" self.first_name = first_name self.last_name = last_name self.age = age self.gender = gender def describe_user(self): full_name = f"{self.first_name} {self.last_name}" print(f"the user name is {full_name.title()}\nage is {self.age}\ngender is {self.gender}") def greet_user(self): print(f"hello,{self.first_name.title()}") user_1 = ('maggie','downey','42','female') user_1.describe_user() user_1.greet_user()
【Python报错】在定义class时,出现AttributeError: ‘tuple‘ object has no attribute ‘describe_user‘
最新推荐文章于 2024-07-06 09:43:08 发布