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

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

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

标签:初始化   不能   src   ace   数据类型   app   list   i know   when   

#英文词频统计
s=‘‘‘What Is Love-Kiesza Mmm.. Ooh.. I don‘t know you‘re not there. I give you my love, but you just don‘t care. Was I right, was I wrong. Give me a sign. What is love? Baby don‘t hurt me, don‘t hurt me, no more. What is love? Baby don‘t hurt me, dont hurt me, no more. Ooh ooh.. I don‘t know, what can I do? What can I say it‘s up to you. I know your right, just me and you. I can‘t go on. What is love? Baby don‘t hurt me, don‘t hurt me, no more. What is love? Baby don‘t hurt me, don‘t hurt me, no more, no more. Ooh, ooh... yeah.. Ooh, ooh, ooh... yeah I want no other, no other lover This is your life, but it‘s our time. But when we are together, I need you forever. Is this love? What is love? Baby don‘t hurt me, don‘t hurt me, no more. What is love? Baby don‘t hurt me, baby don‘t hurt me, no more, no more. don‘t hurt me, no more. Baby don‘t hurt me, no more... no more‘‘‘ s=s.replace(,, ) s=s.replace(., ) s=s.replace(?, ) s=s.replace(, ) s=str.lower(s) s.count(love) s.split( )

技术分享

技术分享

s=list(123321132213)
print(s)

#遍历
s.sort()
print(s)



#查询第一个3分
a=str(s.index(3))
print(第一个三分位置为:+a)


#统计1分的同学的个数
print(一分同学的位置:+str(s.count(1)))


#追加一个同学分数
s.append(2)
print(s)

#删除最后一个同学分数
s.pop()
print(s)

#删除下标为1的同学的分数
s.pop(1)
print(s)

#在下标为1位置插入一个同学分数
s.insert(1,2)
print(s)

技术分享

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

同:tuple。tuple和list非常类似,list格式是用()括起来 tuple格式是使用[ ]括起来

异:tuple一旦初始化就不能修改,而list初始化之后可以修改

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

标签:初始化   不能   src   ace   数据类型   app   list   i know   when   

原文地址:http://www.cnblogs.com/wgd0069/p/7576775.html

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