英文词频统计预备,组合数据类型练习

Posted 叶远超

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了英文词频统计预备,组合数据类型练习相关的知识,希望对你有一定的参考价值。

实例: 下载一首英文的歌词或文章,将所有,.?!等替换为空格,将所有大写转换为小写,统计某几个单词出现的次数,分隔出一个一个的单词。
s=\'\'\'4... 3... 2... 1... no one sleep in Tokyo all right crossing the line no one quit the radio Tokyo is on fire even if you say I have been the world wide I\'ll take you where surely you have never been all right in the fight I\'m OK... come on come on hey do you feel the night is breathable look at this town which is unbelievable no other places like that in the world world world 1 2 3 4 no one sleep in Tokyo all right crossing the line no one quit the radio Tokyo is on fire no one sleep in Tokyo all right crossing the line no one quit the radio Tokyo is on fire turning to the left easy chicks and red lights and to the right crazy music everywhere all right in the fight I\'m OK... come on come on hey do you feel the night is breathable look at this town which is unbelievable no other places like that in the world world world 1 2 3 4 no one sleep in Tokyo all right crossing the line no one quit the radio Tokyo is on fire no one sleep in Tokyo all right crossing the line no one quit the radio Tokyo is on fire come on 1 2 3 4 all right crossing the line Tokyo is on fire hey do you feel the night is breathable look at this town which is unbelievable no other places like that in the world world world 1 2 3 4 no one sleep in Tokyo all right crossing the line no one quit the radio Tokyo is on fire no one sleep in Tokyo all right crossing the line no one quit the radio Tokyo is on fire \'\'\' a = s.lower() b = a.replace(\'.\',\' \') c = b.replace(\'!\',\' \') d = c.replace(\'?\',\' \') e = d.replace(\',\',\' \') f = e.split(\' \') print(f.count(\'tokyo\')) print(f.count(\'no\')) print(f.count(\'one\')) print(f.count(\'fire\'))


 

列表实例:由字符串创建一个作业评分列表,做增删改查询统计遍历操作。例如,查询第一个3分的下标,统计1分的同学有多少个,3分的同学有多少个等。
y = [1,2,3,2,3,2,3,2,1] y y.append(3) y y.insert(4,1) y del y[2] y y.index(3) y.count(1) y.count(3)

 

简要描述列表与元组的异同。

答:创建了一个列表,你就可以添加,删除,或者是搜索列表中的项目;不过元组是不可变的。即你不能修改元组。

以上是关于英文词频统计预备,组合数据类型练习的主要内容,如果未能解决你的问题,请参考以下文章

英文词频统计预备,组合数据类型练习

英文词频统计预备,组合数据类型练习

英文词频统计预备,组合数据类型练习

英文词频统计预备,组合数据类型练习

英文词频统计预备,组合数据类型练习

英文词频统计预备,组合数据类型练习