码迷,mamicode.com
首页 > 其他好文 > 详细

人工智能学习-----第一星期

时间:2018-07-21 22:38:54      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:bre   card   add   chat   str   生成   文件   接受   名片   

  这星期作为学习人工智能开头的第一个星期,从周三开始凌晨5点半出门坐车回来深圳就是为了赶上第一节课。其实,我之前也有python的一点学习经验,但是,感觉如果今天不来上课的感觉会后悔。

  结果和预期一样,只有6个人过来上课,场面始如此的冷清。

  第一个星期好像没什么难度,讲课还是有点快

  生活是如此的冷清,但是心中始终都没有平静过。

      下面始我写的代码!(有一半是自己写的)

 

print(**30,名片打印系统,**30)
print(if you want to add user,please input 1)
print(if you want to delete user,please input 2)
print(if you want to check the system,please input 3)
print(if you want to modify the system,please input 4)
print(if you want to storage user in system,please input 5)
print(if you want to close system,please input 6)

card_info=[]
#创建一个空列表

while True:
    num = input(please input a number :)
    if (not num.isdigit()):
        print(please input the number between 1~6)
        continue #判断输入在1~6之间,是的话就继续
    num=int(num)
    if num==1:
        new_name=input(please input new name:)
        new_QQ =input(please input new QQ)
        new_weChat=input(please input new weChat:)
    #接收参数
        new_cardinfo={}
    #生成新字典
        new_cardinfo[name]=new_name
        new_cardinfo[QQ]=new_QQ
        new_cardinfo[weChat]=new_weChat
    #新的字典接收参数
        card_info.append(new_cardinfo)
    #旧的空字典添加新字典
        print(add new user successful !,(card_info))
    #打印字典
    elif num==2:#delete
        delete_name=input(please input which user your want to delete:)#接收被删除的用户
        delete_flag=0
        for delete in card_info:
            if delete_name==delete[name]:
                del delete[name]
                del delete[QQ]
                del delete[weChat]
                print(delete successful)
                delete_flag=1
            elif delete_flag==0:
                print(No people)

    elif num==3:#check
        check_name = input(please input the name you check!)
        check_flag=0#添加标签
        for check in card_info:
            if check_name==check[name]:#如果接收到的名字在列表中
                print(name:%s\tQQ:%s\tweChat:%s%(check[name],check[QQ],check[weChat]))#输出查询的信息
                check_flag=1
            elif check_flag==0:
                print(No people)
    elif num==4:#modify
        modify_name=input(please input which user you want to modify:)
        modify_flag=0
        for modify in card_info:
            if modify_name==modify[name]:
                print(name:%s\tQQ:%s\tweChat:%s % (modify[name], modify[QQ], modify[weChat]))  # 输出查询的信息
                modify_input=input(please input something you want to modify:)
                if modify_input==modify[name]:
                    new_name=input(please input new name:)
                    new_cardinfo[name]=new_name

                elif modify_input==modify[QQ]:
                    new_QQ=input(please input new QQ:)
                    new_cardinfo[QQ]=new_QQ

                elif modify_input==modify[weChat]:
                    new_weChat=input(please input new weChat:)
                    new_cardinfo[weChat]=new_weChat
                else:
                    print(your input is False)

                modify_flag=1
                print(card_info)
            elif modify_flag==0:
                print(No people!)




    elif num==5:#storage
        storage_name=input(please input which user you want to storage:)
        storage_flage=0
        for storage in card_info:
            if storage_name==storage[name]:
                storage_name=open(%s.txt%(storage[name]),w+)#生成一个文件
                storage_name.write(name:%s\tQQ:%s\tweChat:%s%(storage[name],storage[QQ],storage[weChat]))
                print(storage user successfully!)
                storage_name.close()#写入成功,关闭文件
                storage_flage=1
            elif storage_flage==0:
                print(No people!)


    elif num==6:
        print(Are you sure gonna close system? \n please input yes or no)
        sys=input()
        sys=str(sys) #把接受的转为字符串
        if sys==yes:
            break #
        elif sys==no:
            continue
    else:
        print(your number is out of 1~6,please input again)

 

   

 

 

 

  技术分享图片

人工智能学习-----第一星期

标签:bre   card   add   chat   str   生成   文件   接受   名片   

原文地址:https://www.cnblogs.com/pengjiesheng/p/9348079.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!