首页 > 其他 > 详细

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

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

1

a=‘‘‘After the Winter - Lenka

When the rain is pourin‘ down

And there are snowflakes on your cheeks

When your heart is frozen over

And there is a sea lost sun in weeks

Just remember,

Just remember,

After the winter comes the spring

That is when the blue birds

Starts to sing

And you can always count on this

After the winter comes the spring

When the trees have lost the color

And the sky is full of fears

When you feel you are going under

And your eyes are full of tears

When the bells are all hiding

And you are hiding too

Oh, darling just remember

That everything will soon be new

After the winter comes the spring

That is when the blue birds

Start to use their wings

And you can always count on this

After the winter comes the spring

Just remember,

Just remember,

Just remember,

Just remember,

After the winter comes the spring

That is when the blue birds

Starts to sing

And you can always count on this

After the winter comes the spring

After the winter comes the spring‘‘‘
a=a.lower()
for i in ‘,.?‘:
    a=a.replace(i,‘‘)

print(a.split(‘ ‘))
print(‘remember :‘,a.count(‘remember‘))
print(‘you :‘,a.count(‘you‘))

技术分享

2

grades=list(‘12313561325‘)
for i in range(len(grades)):
    grades[i]=int(grades[i])
print(grades)
print(grades.index(3))
print(grades.count(1))
print(grades.count(3))
技术分享

3

list是处理一组有序项目的数据结构,即你可以在一个列表中存储一个序列的项目。列表中的项目。列表中的项目应该包括在方括号中,这样python就知道你是在指明一个列表。元组通常用在使语句或用户定义的函数能够安全的采用一组值的时候,即被使用的元组的值不会改变。元组可以嵌套。

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

原文:http://www.cnblogs.com/1257-/p/7565131.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!