码迷,mamicode.com
首页 > 编程语言 > 详细

经典案例【Python】

时间:2018-09-15 16:38:44      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:pen   while   存在   bre   NPU   get   enum   16px   font   

dic = {
    植物: {草本植物:
               [冬播, 春播, 二月兰, 紫罗兰, 洋葱, 小麦],
           木本植物:
               [, , 樟树, 乔木],
           藤本本植:
               [扁豆, 牵牛花, 芸豆, 爬山虎]
           },
    动物: {两栖动物:
               [蛙类, 蟾蜍, 大鲵],
           哺乳类动物:
               [, , ],
           爬行动物:
               [鳄鱼, , 大螃蟹哈哈, 知了]
           },
}
li = []
go = True
while go:
    for i, v in enumerate(dic, 1):
        print(i, v)
        li.append(v)
    u_c = str(input(>>>))
    if u_c.isdigit():
        u_c = int(u_c)
        li1 = []
        while go:
            for i, v in enumerate(dic[li[u_c - 1]], 1):
                print(i, v)
                li1.append(v)
            u_c1 = input(>>>)
            u_c1 = int(u_c1)
            while go:
                for i in dic[li[u_c - 1]][li1[u_c1 - 1]]:
                    print(i)
                u_c2 = str(input(>>>))
                u_c2 = u_c2.lower()
                if u_c2 == b:
                    li1.clear()
                    # del li[:] 都是清空的意思
                    break
                elif u_c2 == q:
                    go = False
                    break
    elif u_c.isalpha():
        u_c.lower()
        if u_c == i:
            lx = input(类型:)
            if dic.get(lx, 1) == 1:
                dic[lx] = {}
            zl = input(种类)
            if dic[lx].get(zl, 1) == 1:
                dic[lx][zl] = []
            while True:
                mc = input(名称)
                if mc == q:
                    li.clear()
                    break
                if mc in dic[lx][zl]:
                    print(已经存在)
                else:
                    dic[lx][zl].append(mc)

查询  添加 

经典案例【Python】

标签:pen   while   存在   bre   NPU   get   enum   16px   font   

原文地址:https://www.cnblogs.com/huohu66888/p/9651025.html

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