Chinaunix首页 | 论坛 | 博客
  • 博客访问: 147389
  • 博文数量: 61
  • 博客积分: 1410
  • 博客等级: 上尉
  • 技术积分: 590
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-03 15:26
文章分类

全部博文(61)

文章存档

2010年(9)

2009年(52)

我的朋友

分类: Python/Ruby

2009-04-09 17:10:52

拿出以前练c的技术搞出来速度飞快……丢人ing……


###############################
#phonebook练习
###############################

conactRecord={"pName":"test" , "pNumber":12345}

def main():
    """ main screen for phonebook,just a simple GUI"""
    print("\n\n Welcome to phonebook \n")
    print("\n**************************************\n")
    print("Add new..........................1\n")
    print("Show all.........................2\n")
    print("Search...........................3\n")
    print("Exit.............................0\n")
    print("\n**************************************\n")

    num = int(input("Num you choise : "))
    while(1):
        if 1==num:
            pbookAddNew()
            main()
        elif 2==num:
            pbookShowAll()
            main()
        elif 3==num:
            pbookSearch()
            main()
        elif 0==num:
            exit()
        else:
            main()

def pbookAddNew():
    """add info to pbook"""
    
    print("\n_____ADD A NEW_____")
    newName = input("Please input new contacter name: ")
    newNumber = int(input("Please input new contacter number: "))
    print(newName,newNumber)
    #conactRecord.add()
    
    


def pbookShowAll():
    print("show all")
    for name,number in conactRecord.items():
        print(name,number)

def pbookSearch():
    print("pbookSearch")





作品loseblue创作,采用进行许可。
阅读(665) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~