- 帖子
- 3
- 精华
- 0
- 积分
- 20
- 阅读权限
- 10
- 注册时间
- 2019-1-10
- 最后登录
- 2019-1-27
|
- class entry:
- """号码薄最基础的条目,只包含一个名字"""
- def __init__(self, name):
- self.name = name
- def __str__(self):
- content = ''
- for i in self.item_content:
- content += '{}:{} '.format(i, self.item_content[i])
- return content
- def set_number(self, number, type='cellphone'):
- self.item_content[type] = number
复制代码 在实例中调用 set_number方法会报错
Traceback (most recent call last):
File "D:/pythonworkspace/numberbook/numberbook.py", line 71, in <module>
entries_insert()
File "D:/pythonworkspace/numberbook/numberbook.py", line 61, in entries_insert
new_entry.set_number(str(num_input))
File "D:\pythonworkspace\numberbook\entry.py", line 17, in set_number
self.item_content[type] = number
AttributeError: 'entry' object has no attribute 'item_content'
不知道该怎么改,求救 |
|