赞
踩
一个英文单词包含单词与 词的注释,结构如下:
Words =[{" word ":" about "," note ":"在附近,关于"),(" word ":" post "," note ":"邮寄、投递"}]
所有的单词组成一个列表,每个单词与注释成为一个字典,程序的功能就是管理这样一组单词记录,程序有查找单词、增加单词、更新注释、删除单词、显示单词等功能
- # 定义单词列表
- words = [{"word": "about", "note": "在附近,关于"},
- {"word": "post", "note": "邮寄、投递"}]
-
-
- # 查找单词函数
- def search_word():
- word = input("请输入要查找的单词:") # 遍历单词列表,查找相应单词
- for w in words:
- if w["word"] == word:
- print(f"{word}: {w['note']}")
- return
- print("该单词不在记录中")
-
-
- # 增加单词函数
- def add_word():
- word = input("请输入要添加的单词:") # 判断该单词是否已经在记录中,避免重复添加
- for w in words:
- if w["word"] == word:
- print("该
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。