9/20

Posted 23江瑜斌

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了9/20相关的知识,希望对你有一定的参考价值。

    1. 列表实例:由字符串创建一个作业评分列表,做增删改查询统计遍历操作。例如,查询第一个3分的下标,统计1分的同学有多少个,3分的同学有多少个等。
      score=list(\'112233345611\')
      print(\'分数为:\')
      print(score)
      score.sort()
      print(\'排列后:\')
      print(score)
      print(\'计数1:\')
      print(score.count(\'1\'))
      print(\'计数3:\')
      print(score.count(\'3\'))
      score.pop(5)
      print(score)
    2. 字典实例:建立学生学号成绩字典,做增删改查遍历操作。
      zd={"江雨斌":"90","张侦讯":"98","黄志涛":"77","梁浩燃":"88"}
      print(zd)
      zd[\'王文杰\']=\'59\'
      print(zd)

       

    3. 列表,元组,字典,集合的遍历。
      总结列表,元组,字典,集合的联系与区别。
      lb=list(\'1223334444455555666666\')
      yz=tuple(\'1223334444455555666666\')
      jh=set(\'1223334444455555666666\')
      zd={"jyb":"b6014","zzx":"b5008","hzt":"b6016"}
      print(\'列表遍历:\')
      print(lb)
      for i in lb:
          print(i,end=\' \')
      print(\'\\n\')
      print(\'元组遍历:\')
      for i in yz:
          print(i,end=\' \')
      print(\'\\n\')
      print(\'集合遍历:\')
      for i in jh:
          print(i,end=\' \')
      print(\'\\n\')
      print(\'字典遍历:\')
      for i in zd:
          print(i,end=\' \')

    4. 英文词频统计实例
      1. 待分析字符串
      2. 分解提取单词
        1. 大小写 txt.lower()
        2. 分隔符\'.,:;?!-_’
      3. 计数字典
      4. 排序list.sort()
      5. 输出TOP(10)
        panama=\'\'\'Daca nici asa nu-ti place
        Ia mai zboara-n Panama
        Zile zile zile zile eu alerg girl
        Mile mile mile mile pe maidan
        Pentru tine tine sa-ti dau un dar dar
        Cel mai de pret dar fara nici un ban ban
        Ganja iarba sunt inutile-tile
        Numai tu stii sa-mi dai aripile-pile
        In Jamaica sau in Chile Chile
        Inima face Boom-Boom numai pentru tine
        Eh eh eh eh eh eh eh eh eh eh
        Numai pentru tine
        Eh eh eh eh eh eh eh eh eh eh
        N-ai raspuns la telefon
        No problem te scot pe balcon
        Si-o sa vezi cu ochii tai
        Cum ti-aduc flori un camion
        Si iti cant asa cu chitara mea
        Daca nici asa nu-ti place
        Ia mai zboara-n Panama
        Ce pana mea
        Ah ah ah ah mai zboara-n Panama
        Ah ah ah ah zboara ce pana mea
        Ah ah ah ah mai zboara-n Panama
        Ah ah ah ah hai mai zboara
        Kile-kile kile-kile eu am dat jos
        Oricum baby nu erau de folos-los
        Mi-e dor de tine sunt intors pe dos-dos
        Acasa ajung la timp tre' sa o iau pe jos-jos
        La ce ne folosesc banii banii banii
        Daca tu imi dai iubire si zi de zi pun anii
        Ca Bonnie Clyde sa fiu doar eu cu tine
        Si o sa avem girl o iubire ca in filme
        Eh eh eh eh eh eh eh eh eh eh
        O iubire ca in filme
        Eh eh eh eh eh eh eh eh eh eh Eh
        N-ai raspuns la telefon
        No problem te scot pe balcon
        Si-o sa vezi cu ochii tai
        Cum ti-aduc flori un camion
        Si iti cant asa cu chitara mea
        Daca nici asa nu-ti place
        Ia mai zboara-n Panama Ce pana mea
        Ah ah ah ah mai zboara-n Panama
        Ah ah ah ah zboara ce pana mea
        Ah ah ah ah mai zboara-n Panama
        Ah ah ah ah Eh Oh no
        Baby girl hai vino incoa'
        Am dragoste la mine o dau la schimb cu a ta
        Baby girl dragostea mea
        E de calitate dau gramul gram hai ia
        N-ai raspuns la telefon
        No problem te scot pe balcon
        Si-o sa vezi cu ochii tai
        Cum ti-aduc flori un camion
        Si iti cant asa cu chitara mea
        Daca nici asa nu-ti place
        Ia mai zboara-n Panama Ce pana mea
        Ah ah ah ah mai zboara-n Panama
        Ah ah ah ah zboara ce pana mea
        Ah ah ah ah mai zboara-n Panama
        Ah ah ah ah hai ma zboara Pwaah\'\'\'
        panama=panama.replace(\'?\',\' \')
        panama=panama.replace(\'!\',\' \')
        panama=panama.replace(\',\',\' \')
        panama=panama.replace(\'.\',\' \')
        panama=panama.replace(\'-\',\' \')
        panama=panama.replace(\'&\',\' \')
        panama=panama.lower()
        
        words=panama.split(\' \')
        zd={}
        key=set(words)
        for i in key:
            zd[i]=words.count(i)
        lb=list(zd.items())
        lb.sort(key=lambda x:x[1],reverse=True)
        print(\'频率最高top10:\\n\')
        for i in range(10):
            print(lb[i])

         

以上是关于9/20的主要内容,如果未能解决你的问题,请参考以下文章

微信小程序代码片段

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器