Products
GG网络技术分享 2025-11-13 20:30 2
python
scores = {'Lucy': 90, 'Tom': 85, 'John': 92} grades = {score: name for name, score in scores.items} print # 输出:{90: 'Lucy', 85: 'Tom', 92: 'John'}

data = {'Python': 1, 'is': 2, 'a': 3, 'popular': 4, 'programming': 5, 'language': 6, 'that': 7, 'easy': 8, 'to': 9, 'learn': 10, 'and': 11, 'use': 12} print
dic = {'name': 'Lucy', 'age': 20, 'sex': 'female'} print # 输出:Lucy dic = 21 print # 输出:{'name': 'Lucy', 'age': 21, 'sex': 'female'} dic = 'Beijing' print # 输出:{'name': 'Lucy', 'age': 21, 'sex': 'female', 'address': 'Beijing'} del dic print # 输出:{'name': 'Lucy', 'age': 21, 'address': 'Beijing'}
text = "Python is a popular programming language that is easy to learn and use" words = text.split dic = {} for word in words: if word in dic: dic += 1 else: dic = 1 print
Demand feedback