0
我正在使用python的PhoneBook,我有一個類,我希望用戶通過raw_input調用實例。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()?
提前致謝!
是的印刷只是爲了測試。好的,謝謝你的幫助! – simtaxman
@ingen以爲:p。沒問題:D – TerryA
可以說我想將輸入的一部分發送到Add()函數,因爲Add()將給電話簿添加名稱,我該怎麼做? – simtaxman