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

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 
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"
>>> 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、简要描述列表与元组的异同。

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

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

原文地址:https://www.cnblogs.com/Sun584125503/p/7562029.html