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

Posted 我是大王哈哈哈

tags:

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

1、增删查改

>>> g=list(‘456123456‘)
>>> g
[‘4‘, ‘5‘, ‘6‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘]
>>> for i in range(len(g)):
	g[i]=int(g[i])

	
>>> g
[4, 5, 6, 1, 2, 3, 4, 5, 6]
>>> g.append(1)
>>> g
[4, 5, 6, 1, 2, 3, 4, 5, 6, 1]
>>> g.pop()
1
>>> g
[4, 5, 6, 1, 2, 3, 4, 5, 6]
>>> g[0]=3
>>> g
[3, 5, 6, 1, 2, 3, 4, 5, 6]
>>> g.index(1)
3
一分个数与三分个数
>>> g.count(1) 1 >>> g.count(3) 2
查询第一个三分下标
>>> g.index(3) 0

  

  

 

  2、英文歌的一些操作

>>> abc=‘‘‘every night in my dreams 
i see you, i feel you,
that is how i know you go on 
far across the distance 
and spaces between us 
you have come to show you go on 
near, far, wherever you are 
i believe that the heart does go on 
once more you open the door 
and you‘re here in my heart 
and my heart will go on and on 
love can touch us one time 
and last for a lifetime 
and never let go till we‘re one 
love was when i loved you 
one true time i hold to 
in my life we‘ll always go on 
near, far, wherever you are 
i believe that the heart does go on 
once more you open the door 
and you‘re here in my heart 
and my heart will go on and on 
there is some love that will not go away 
you‘re here, there‘s nothing i fear,
and i know that my heart will go on 
we‘ll stay forever this way 
you are safe in my heart 
and my heart will go on and on‘‘‘
>>> abc.lower()
"every night in my dreams \ni see you, i feel you,\nthat is how i know you go on \nfar across the distance \nand spaces between us \nyou have come to show you go on \nnear, far, wherever you are \ni believe that the heart does go on \nonce more you open the door \nand you‘re here in my heart \nand my heart will go on and on \nlove can touch us one time \nand last for a lifetime \nand never let go till we‘re one \nlove was when i loved you \none true time i hold to \nin my life we‘ll always go on \nnear, far, wherever you are \ni believe that the heart does go on \nonce more you open the door \nand you‘re here in my heart \nand my heart will go on and on \nthere is some love that will not go away \nyou‘re here, there‘s nothing i fear,\nand i know that my heart will go on \nwe‘ll stay forever this way \nyou are safe in my heart \nand my heart will go on and on"
>>> print(abc.count(‘in‘))
6
>>> print(abc.replace(‘,‘,‘ ‘))
every night in my dreams 
i see you  i feel you 
that is how i know you go on 
far across the distance 
and spaces between us 
you have come to show you go on 
near  far  wherever you are 
i believe that the heart does go on 
once more you open the door 
and you‘re here in my heart 
and my heart will go on and on 
love can touch us one time 
and last for a lifetime 
and never let go till we‘re one 
love was when i loved you 
one true time i hold to 
in my life we‘ll always go on 
near  far  wherever you are 
i believe that the heart does go on 
once more you open the door 
and you‘re here in my heart 
and my heart will go on and on 
there is some love that will not go away 
you‘re here  there‘s nothing i fear 
and i know that my heart will go on 
we‘ll stay forever this way 
you are safe in my heart 
and my heart will go on and on

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

     元组一旦初始化就不能改变里面的元素,而列表可以。

     列表中的项目应该包括在方括号中,元组在圆括号中
     你可以增删改或是搜索列表中的项目。

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

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

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

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

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

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

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