Case: Python list nested dictionary implementation memo

Source: Internet
Author: User

1. Use a dictionary and list nesting structure to represent multiple records
2. When adding information, enter a word directly, parse and disassemble, and record time and event
3. Different color output with different information

#!/user/bin/env Python# _*_ coding:utf-8 _*_# 51memo.py# author:大宝dayday见__author__ = ‘大宝dayday见‘desc = ‘51备忘录‘.center(30,‘-‘)print(desc)welcome = ‘welcome‘print(f‘{welcome}作者:‘,__author__)# 添加备忘信息"""dict = {‘time‘:‘8点‘,           ‘thing‘:‘起床‘        }"""all_memo = []is_add = Truewhile (is_add):    one = {}    info = input(‘请输入备忘信息:‘)    one[‘时间‘] = info[info.find(‘点‘)-1:info.find(‘点‘)+1]    one[‘事件‘] = info[info.find(‘点‘)+1:]    all_memo.append(one)    print(f‘备忘录{all_memo}‘)    num = 0    for i in all_memo:        num += 1        print(‘项目%s:%s‘ %(num,i))    print(f‘共{len(all_memo)}个待办事项‘,end=‘‘)    is_add = input(‘是否继续 Y/N:‘) == ‘Y‘
------------51备忘录-------------welcome作者: 大宝dayday见请输入备忘信息:杰伦,今晚8点K歌备忘录[{‘时间‘: ‘8点‘, ‘事件‘: ‘K歌‘}]项目1:{‘时间‘: ‘8点‘, ‘事件‘: ‘K歌‘}共1个待办事项是否继续 Y/N:Y请输入备忘信息:圆圆,明天9点按时起床备忘录[{‘时间‘: ‘8点‘, ‘事件‘: ‘K歌‘}, {‘时间‘: ‘9点‘, ‘事件‘: ‘按时起床‘}]项目1:{‘时间‘: ‘8点‘, ‘事件‘: ‘K歌‘}项目2:{‘时间‘: ‘9点‘, ‘事件‘: ‘按时起床‘}共2个待办事项是否继续 Y/N:N    print(‘\033[34;1m"我是蓝色"\033[0m‘)    print(‘\033[32;1m"我是绿色"\033[0m‘)    print(‘\033[33;1m"我是×××"\033[0m‘)    print(‘\033[31;1m"我是红色"\033[0m‘)

Case: Python list nested dictionary implementation memo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.