zoukankan      html  css  js  c++  java
  • 英文词频统计预备,组合数据类型练习

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

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

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

  • 相关阅读:
    WPF杂难解 图片模糊的暂时解决方案
    wpf学习笔记 NotifyPropertyChanged实现数据变化自动更新UI
    WPF杂难解 粘贴板复制GIF图片时丢失透明背景
    WPF杂难解 RichTextBox粘贴图片地址处理,并保存的问题
    wpf学习笔记 依赖属性
    WPF杂难解 中文字体显示模糊
    雪花型,支架型,和桥型 的区别
    BI工具对比
    关于javac不是内部命令的解决办法
    转载 android listview getview() 反复调用
  • 原文地址:https://www.cnblogs.com/Sun584125503/p/7562029.html
Copyright © 2011-2022 走看看