猫史档案馆


【Python作品分享】dic

用户:勇敢的月见花isyQ勇敢的月见花isyQ查看:0 回复:0 评论:0 创建时间:2020-09-16T19:11:57


【作品展示】

center_image

 

【作品介绍】

一个字典

 

【作品源代码】


dic = {}
while True:
    a = input('dictionary\na for add \nl for look\ns for start with\nq for quit')
    if a == 'a':
        word = input("word ")
        def_ = input("defintion ")
        dic[word] = def_ 
        print("end\n-------------------")
        mi_dic[word] = def_
        pickle.dump(mi_dic)

    elif a == 'l':
        word = input('word')
        if word in dic.keys():
            print(dic[word], "\nend\n-------------------")
        else:
            print("isn`t in dictionary\nend\n-------------------")
    elif a == 's':
        up = input('the start')
        for i in range(len(dic)):
            list_ = list(dic)#using index
            if list_[i].startswith(up):
                
                print(list_[i], "starts with", up, "\nend\n-------------------")

    elif a == 'q':
        print("all of your dic will be delete")
        if input('ready?(y/n)') == 'y':
            break
#字典程序

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页