## 习题P87

"""

"""
print(dic.__len__())


"""

"""
dic1={
'java': 98
}
dic.update(dic1)
print(dic)


"""

"""
del dic['c']
print(dic)


"""

"""
dic1={
'php': 90
}
dic.update(dic1)
print(dic)


"""

"""
print(list(dic.keys()))
"""

"""
print(list(dic.values()))


"""

"""
if 'javascript' in dic:
print("存在")
else:
print("不存在")
"""

"""
lst=list(dic.values())
sum=0
for i in lst:
sum+=i
print(sum)
"""

"""
print(max(dic.values()))
"""

"""
print(min(dic.values()))
"""

"""
dicl = {'php': 97}
dic.update(dicl)
print(dic)


2.

data = {
'python': {'上学期': '90', '下学期': '95'},
'C++': ['95', '96', '97'],
'java': [{'月考':'90',' 期中考试': '94', '期末考试': '98'}]
}
def transfer_score(data):
dic = {}
key = list(data.keys())
value = list(data.values())
for i in range(len(key)):
if type(value[i]) == list:
for j in range(len(value[i])):
if type(value[i][j]) == dict:
dic1 = value[i][j]
dic2 = {}
dic1k = list(dic1.keys())
dic1v = list(dic1.values())
for k in range(len(dic1v)):
dic1v[k] = int(dic1v[k])
for k in range(len(dic1k)):
dic2[dic1k[k]] = dic1v[k]
value[i][j] = dic2
if type(value[i][j]) == str:
value[i][j] = int(value[i][j])
if type(value[i]) == dict:
dic1 = value[i]
dic2 = {}
dic1k = list(dic1.keys())
dic1v = list(dic1.values())
for k in range(len(dic1v)):
dic1v[k] = int(dic1v[k])
for k in range(len(dic1k)):
dic2[dic1k[k]] = dic1v[k]
value[i] = dic2
for i in range(len(key)):
dic[key[i]] = value[i]
return dic
data = transfer_score(data)
print(data)


• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 手机看

分享到微信朋友圈

x

扫一扫，手机阅读

• 打赏

打赏

建国后的猫精

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文

05-26