!/usr/bin/env python
coding:utf-8
host_info = [
['CPU 信息', '我是 cpu 信息',''],
['MEM 信息', '我是内存信息','']
]
menu_list = [
['主机信息', '', host_info],
['运维工工具箱', '我是运维工工具箱', ''],
]
menu_dict = {}
menu = ['title', 'func', 'next_menu']
for i, item in enumerate(menu_list, 1):
menu_dict.update({i: {"title":item[0],'func':item[1],'next_menu':item[2]}})
print(menu_dict)
while True:
for j in range(len(menu_dict)):
print(list(menu_dict.keys())[j], list(menu_dict.values())[j].get('title'))
# print(list(menu_dict.values())[j].get('title'))
c = input("请选择>>:")
if c.isdigit():
c = int(c)
if c == 1 :
print(menu_dict.get(c).get('func'))
exit()
if c == 2 :
print(menu_dict.get(c).get('func'))
exit()