python中的字典操作及字典函数

yt96967yt 151 0 PDF 2020-12-31 01:12:29

字典 dict_fruit = {'apple':'苹果','banana':'香蕉','cherry':'樱桃','avocado':'牛油果','watermelon':'西瓜'} 字典的操作 #字典的遍历方式 #默认遍历(遍历key) for value in dict_fruit: print(value) ''''' 遍历出的值: watermelon apple cherry avocado banana ''' #使用key遍历(与默认遍历一样) for key in dict_fruit.keys(): print(key) ''''' 遍历出的值: waterm

用户评论
请输入评论内容
评分:
暂无评论