码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-09-20 21:55:20      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:lower   this   创建   操作   字符   英文   练习   dex   blog   

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

str=‘‘‘Leshi Holding (Beijing) Co, the company controlled by LeEco founder Jia Yueting, has repaid debt of more than 100 million yuan ($15 million) to its suppliers, according to a report by Securities Daily.

"Leshi Holding signed repayment deals with 28 suppliers last week and will do it with another 27 suppliers this week," a Leshi Holding insider told Securities Daily on Tuesday.

Most of the suppliers that have reached settlements with Leshi Holding are smartphone store contractors of LeMobile‘s LePhone, the report said.‘‘‘
for i in ,.?:
    str=str.replace(i, )

str=str.lower()
write=str.split( )
print(str)
print(str.count(it))

技术分享

2.

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

g=list(12313561325)
for i in range(len(g)):
    g[i]=int(g[i])
print(g)
print(第1个3分下标为:,g.index(3))
print(1分的有:,g.count(1))
print(3分的有:,g.count(3))

技术分享

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

列表和元组都是序列类型,不过元组是不可变的。即你不能修改元组。元组通过圆括号中用逗号分隔的项目定义。

 

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

标签:lower   this   创建   操作   字符   英文   练习   dex   blog   

原文地址:http://www.cnblogs.com/123hi/p/7565025.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!