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

Posted wtaure

tags:

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

#英文词频统计
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初始化之后可以修改

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

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

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

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

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

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

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