Commit 73e9196f by BellCodeEditor

auto save

parent 3b4f8e15
Showing with 22 additions and 0 deletions
score = {'语文':91,'数学':88,'英语':85}
# 请对字典进行遍历,将保存的分数以键值对的形式提取打印出来
#keys()方法对字典中所有的键进行遍历
for k in score.keys():
print(k)
#遍历字典中所有的值 通过values()进行遍历
for v in score.values():
print(v)
#遍历字典中的键值对 通过items()进行遍历
for k,v in score.items():
print(k,v)
#如何删除元素 pop()删除字典中的某个值
print(score.pop("英语"))
print(score)
#clear()清空字典
score.clear()
print(score)
#del 删除字典
del score
print(score)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment