我正在用python编写电话簿,我有一个类,我希望用户通过raw_input调用实例。
例如
class PhoneBook():
def Add(self):
print "Name added"
def main():
pb = PhoneBook()
Input = raw_input()
#Here I want to call pb.add() (and in the future other alternatives)
#using the string Input. As I want it (but I know doesn't work): pb.Input[0]
#provided the user types Add
是否可以使用字符串调用 pb.Add()?
提前致谢!