classUser():def__init__(self,first,last):self.first=firstself.last=lastdefdescribe_user(self,**info):profile={}profile['first_name']=self.firstprofile['last_name']=self.l...
class User():
def __init__(self,first,last):
self.first=first
self.last=last
def describe_user(self,**info):
profile={}
profile['first_name']=self.first
profile['last_name']=self.last
for key,value in self.info.items():
profile[key]=value
return profile
my_message=User('yuki','lee')
my_message.describe_user(age='27',gender='female')
以上内容是写一段关于用户信息的类,程序运行报错,以下为报错信息
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
11 return profile
12 my_message=User('yuki','lee')
---> 13 my_message.describe_user(age='27',gender='female')
in describe_user(self, **info)
7 profile['first_name']=self.first
8 profile['last_name']=self.last
----> 9 for key,value in self.info.items():
10 profile[key]=value
11 return profile
AttributeError: 'User' object has no attribute 'info'
能有大神解答下怎么改吗?
展开