转载

列表、元组、字典、集合的定义、操作与综合练习

l = ['Michael','Bob','Tracy']
l.append('Bob')
l.pop()
print(1)

t = ('Michael','Bob','Tracy')

scores = [85,65,55]

d = {'Michael':85,'Bob':65,'Tracy':55}
d['Bob'] = 82
d['Rose'] = 88
d.pop('Bob')

print(d)

sl = {'Michael','Bob','Tracy'}
s2 = {'Michael',2,3}
sl.add(12)
s2.remove(3)
print(sl,s2)

dl = dict(zip(l,scores))
print(1)
print(scores)
print(dl)

  

totalStr='201709080012何倩仪 201709080057欧雪莹 201709080046冯碧怡 201709080056宁美欣   201709080028梁珍瑜、'
totalList=totalStr.split(' ')
totalset=set (totalList)
print(totalList)
print(totalset)



totaldict={}
for d in totalset :
    totaldict [d] =totalList.count(d)
print(totaldict)

  

转载于:https://www.cnblogs.com/Sally-0820/p/9147517.html

正文到此结束
本文目录