作为一个菜鸟, 没点进步都是值得记录的. 嘿嘿, 今天重新看了一遍Python简明教程, 终于独立完成了最后的练习(老鸟勿笑). 特粘贴代码在下面,希望大家指导.
import cPickle class Person: '''Represents a person,which includes name, phone, email and so on.''' phonebook = {} #Create a dict for storing the contact def __init__(self): self.name = '' self.phone = '' self.email = '' def add(self): '''Add a contact.''' self.name = raw_input('Please input a name: ') if Person.phonebook.has_key(self.name): print 'The name is exist!' else: self.phone = raw_input('Please input the phone: ') self.email = raw_input('Please