组合数据练习,英语词频统计实例上
Posted 咖啡coffee
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了组合数据练习,英语词频统计实例上相关的知识,希望对你有一定的参考价值。
1
>>> d={\'01\':95,\'02\':92,\'03\':86,\'04\':70}
>>> print(d)
{\'01\': 95, \'02\': 92, \'03\': 86, \'04\': 70}
>>> d[\'05\']=80
>>> print(d)
{\'01\': 95, \'02\': 92, \'03\': 86, \'04\': 70, \'05\': 80}
>>> d.pop(\'02\')
92
>>> print(d)
{\'01\': 95, \'03\': 86, \'04\': 70, \'05\': 80}
>>> d[\'03\']=88
>>> print(d)
{\'01\': 95, \'03\': 88, \'04\': 70, \'05\': 80}
>>> d[\'05\']
80
2
ls=list(\'2345679900\')
tu=tuple(\'2354687879\')
print(ls)
print(tu)
dc=dict(zip(ls,tu))
print(dc)
print(\'ls遍历\\n\')
for i in ls:
print(i)
print(\'tu遍历\\n\')
for i in tu:
print(i)
print(\'dict遍历\\n\')
for i in dc:
print(i,dc[i])
3
列表和元组是有序的,字典和集合是无序的,列表是可变的数据类型,即这种类型是可以被改变的,并且列表是可以嵌套的,列表通过中括号中用逗号分隔的项目定义。元组是不可变的。即你不能修改元组。元组通过圆括号中用逗号分隔的项目定义。元组通常用在使语句或用户定义的函数能够安全的采用一组值的时候,即被使用的元组的值不会改变。元组可以嵌套。字典通过大括号中用键值对和逗号分隔的项目定义,用空间换取时间。集合只有键没有值,可以把元组或序列中不重复的找出来,并可以做交集并集等操作
4
song=\'\'\'I don\'t like your little games
Don\'t like your tilted stage
The role you made me play of the fool
No I don\'t like you
I don\'t like your perfect crime
How you laugh when you lie
You said the gun was mine
Isn\'t cool
No I don\'t like you ooh
But I got smarter I got harder in the nick of time
Honey I rose up from the dead I do it all the time
I got a list of names and yours is in red underlined
I check it once then I check it twice ooh
Ooh look what you made me do
Look what you made me do
Look what you just made me do
Look what you just made me
Ooh look what you made me do
Look what you made me do
Look what you just made me do
Look what you just made me do
I don\'t like your kingdom keys
They once belonged to me
You asked me for a place to sleep
Locked me out and threw a feast what
The world moves on another day another drama drama
But not for me not for me all I think about is karma
And then the world moves on but one thing\'s for sure
Maybe I got mine but you\'ll all get yours
But I got smarter I got harder in the nick of time
Honey I rose up from the dead I do it all the time
I\'ve got a list of names and yours is in red underlined
I check it once then I check it twice ooh
Ooh look what you made me do
Look what you made me do
Look what you just made me do
Look what you just made me
Ooh look what you made me do
Look what you made me do
Look what you just made me do
Look what you just made me do
I don\'t trust nobody and nobody trusts me
I\'ll be the actress starring in your bad dreams
I don\'t trust nobody and nobody trusts me
I\'ll be the actress starring in your bad dreams
I don\'t trust nobody and nobody trusts me
I\'ll be the actress starring in your bad dreams
I don\'t trust nobody and nobody trusts me
I\'ll be the actress starring in your bad dreams
Look what you made me do
Look what you made me do
Look what you made me do
I\'m sorry the old Taylor can\'t come to the phone right now
Why
Oh \'cause she\'s dead ohh
Ooh look what you made me do
Look what you made me do
Look what you just made me do
Look what you just made me
Ooh look what you made me do
Look what you made me do
Look what you just made me do
Look what you just made me do
Ooh look what you made me do
Look what you made me do
Look what you just made me do
Look what you just made me
Ooh look what you made me do
Look what you made me do
Look what you just made me do
Look what you just made me do\'\'\'
song=song.lower()
song=song.replace(\'\\n\',\' \')
word=song.split(\' \')
dic={}
keys=set(word)
for i in keys:
dic[i]=word.count(i)
print(dic)
以上是关于组合数据练习,英语词频统计实例上的主要内容,如果未能解决你的问题,请参考以下文章