博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
英文词频统计预备,组合数据类型练习
阅读量:4470 次
发布时间:2019-06-08

本文共 1680 字,大约阅读时间需要 5 分钟。

1.实例: 下载一首英文的歌词或文章,将所有,.?!等替换为空格,将所有大写转换为小写,统计某几个单词出现的次数,分隔出一个一个的单词。

s='''I'm a big big girl !

In a big big world !
It's not a big big thing if you leave me.
But I do do feel.
That I too too will miss you much.
Miss you much !
I can see the first leaf falling.
It's all yellow and nice.
It's so very cold outside.
Like the way I'm feeling inside.
I'm a big big girl !
In a big big world !
It's not a big big thing if you leave me.
But I do do feel.
That I too too will miss you much.
Miss you much !
Outside it's now raining.
And tears are falling from my eyes.
Why did it have to happen ?
Why did it all have to end ?
I'm a big big girl !
In a big big world !
It's not a big big thing if you leave me.
But I do do feel.
That I too too will miss you much.
Miss you much !
I have your arms around me warm like fire.
But when I open my eyes.
You're gone !
I'm a big big girl !
In a big big world !
It's not a big big thing if you leave me.
But I do do feel.
That I too too will miss you much.
Miss you much !
I'm a big big girl !
In a big big world !
It's not a big big thing if you leave me.
But I do feel that will miss you much !
Miss you much ! '''
s=s.lower()
s=s.replace('.',' ')
s=s.replace('!',' ')
s=s.split(' ')
print(s)
print('I出现的次数:',d.count('I'))
print('big出现的次数:',d.count('big'))

 

2. 列表实例:由字符串创建一个作业评分列表,做增删改查询统计遍历操作。例如,查询第一个3分的下标,统计1分的同学有多少个,3分的同学有多少个等。

s=list('345665435643786543')

print(s)
print("3分的人数:",s.count('3'))
print("5分的人数:",s.count('5'))
s.append('8')
print('增加一个同学的成绩为8:',s)
print('修改下标为6的同学的分数为7:',s)

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

 答:列表list是处理一组有序项目的数据结构,可以在一个列表中存储一个序列的项目。元组和列表十分相似,不过元组是不可变的,即不能修改元组,元组通过圆括号中用逗号分隔的项目定义。

转载于:https://www.cnblogs.com/xyjie/p/7577339.html

你可能感兴趣的文章
C# 子线程与主线程通讯方法一
查看>>
006——修改tomacat的编码
查看>>
《C程序设计语言》笔记 (八) UNIX系统接口
查看>>
git常用命令
查看>>
Android必知必会-获取视频文件的截图、缩略图
查看>>
(转)理解Bitblt、StretchBlt与SetDIBitsToDevice、StretchDibits
查看>>
python之路-基础篇-第七周
查看>>
ViurtualBox配置虚拟机Linux的网络环境
查看>>
VLC 媒体播放器
查看>>
勿忘国耻2018/09/18
查看>>
Jenkins部署码云SpringBoot项目
查看>>
多标签分类(multi-label classification)综述
查看>>
史上最全面的Spring-Boot-Cache使用与整合
查看>>
图的遍历(深度优先与广度优先搜索两种方案)
查看>>
快速读入模板
查看>>
impdp报错: ORA-39064: 无法写入日志文件 ORA-29285: 文件写入错误
查看>>
\n ^ \t的使用
查看>>
css盒模型
查看>>
探索式测试:测试自动化
查看>>
用 UIWebView 代替 UITextView,解决行间距问题
查看>>