失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > 组合数据类型练习 英语词频统计

组合数据类型练习 英语词频统计

时间:2020-05-22 18:52:35

相关推荐

组合数据类型练习 英语词频统计

字典实例:建立学生学号成绩字典,做增删改查遍历操作。

di={}di["001"]=76di["002"]=87di["003"]=79di["004"]=98di["005"]=72print(di)di["006"]=95print(di)del(di['005'])print(di)for i in di:print(i,di[i])

列表,元组,字典,集合的遍历。

总结列表,元组,字典,集合的联系与区别。

w=list('154896')e=tuple('564255')t=dict(zip(w,e))u=set([5,3,8,8,6,1])for i in w:print(i)for i in e:print(i)for i in t:print(i,t[i])for i in u:print(i)

英文词频统计实例待分析字符串分解提取单词大小写 txt.lower()分隔符'.,:;?!-_’单词列表单词计数字典

lp='''You hid your skeletons, when I had shown you mine

you woke the devil that I thought you left behind

I saw the evidence the crimson soaking through

ten thousand promises, ten thousand ways to lose...

And you held It all

but you were careless to let it fall

you held it all

and I was by your side

Powerless

I watched you fall apart

and chased you to the end

I'm left an empty mess, that words can not defend

you'll never know what I became

because of you

ten thousand promises, ten thousand ways to lose...

And you held It all

but you were careless to let it fall'''

less=lp.lower()

print(less)

for i in ",...'":

lp=less.replace(i," ")

print(lp)

power=lp.split()

print(power)

dic={}

for i in power:

dic[i]= power.count(i)

lp=list(dic.items())

print('单词计数字典:',lp)

)

如果觉得《组合数据类型练习 英语词频统计》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。