Commit 7fd3003d by BellCodeEditor

auto save

parent 5ab88987
Showing with 26 additions and 1 deletions
x = 5
if x%2 ==0:
print("偶数")
else:
print("奇数")
\ No newline at end of file
score = {'语文':91,'数学':88,'英语':85}
# 请对字典进行遍历,将保存的分数以键值对的形式提取打印出来
st = {"张三":score,"李四":socre,"王五":score} # 字典中嵌套了字典
# 按键遍历字典
print("**一、直接用字典名字**")
print(" **1、直接用字典名字**")
for i in score: # 一直接用字典名字
print(i)
print(" **2、用字典的keys方法**")
for i in score.keys(): # 二用字典的keys方法
print(i)
print("**二、按值遍历字典**")
for i in score.values():
print(i)
print("**三、按键值对遍历字典**")
for k,v in score.items():
print(k,v)
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