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

    1.

    d={'林彬':'01','卢本伟':'03','pdd':'03'}
    print(d['林彬'])

    d.pop('pdd')
    print(d)
    print(d.items())

    d['ty']='12'
    print(d)

    2.

    ls=list('123456')
    print(ls)
    for i in ls:
        print(i)

    tu=tuple('123456')
    print(tu)
    for i in tu:
        print(i)

    x=list('123456')
    y=tuple('abcdef')
    z=dict(zip(y,x))
    print(z)
    for i in z:
        print(i,z[i])

    jihe=set('456')
    print(jihe)
    for i in jihe:
        print(i)

    元组和列表十分类似,只不过元组和字符串一样是不可变的,即你不能修改元组。元组是任意对象的有序集合,数组的同性。

    列表是任意对象的有序集合;可通过偏移存取,注意,列表中的元素都是可变的,这是不同于元组的。

    在字典里,不能再有序列操作,虽然字典在某些方面与列表类似,但不要把列表套在字典上。

    集合才能做并、交集的运算。

     3.

    news='''We don't talk anymore
    We don't talk anymore
    We don't talk anymore
    Like we used to do
    We don't laugh anymore
    What was all of it for ?
    We don't talk anymore
    Like we used to do
    I just heard you ( ya ) found the one you'vebeen lookin'
    You been looking for
    I wish i would've konwn that wasn't me
    Cause even after all this time i still wonder
    Why i can't move on ?
    Just the way you dance so easliy
    Don't wanna know
    The kinda (kind of) dress you're wearin' tonight
    If he's holdin' onto you so tight
    The way i did before
    I overdosed
    Should've known your love was game
    Now I can't get'cha outof my brain
    Ooh it's such a shame
    We don't talk anymore
    We don't talk anymore
    We don't talk anymore
    Like we used to do
    We don't laugh anymore
    What was all of it for ?
    We don't talk anymore
    Like we used to do
    Selena : I just hope you'r lyin' next to somebody
    Know it's hard to love yalike me
    Must be a good reason that you're gone
    Every now and then
    I think you might want me to come show up yourdoor
    But I'm just too afraidthat i'll be worng
    Don't wanna know
    If you'ra lookin' intoher eyes
    If she's holdin' onto youso tight
    The way i did before
    I overdosed
    Should've know your lovewas a game
    Now I can't get'cha outof my brain
    Ooh it's such a shame
    We don't talk anymore
    We don't talk anymore
    We don't talk anymore
    Like we used to do
    We don't laugh anymore
    What was all of it for ?
    We don't talk anymore
    Like we used to do
    Charlie: Like we used to do
    Don't wanna know
    The kinda dress you'rewearin' tonight
    If he's givin' it to youjust right
    The way i did before
    S: I overdosed
    Should've know your lovewas a game
    Now I can't get'cha outof my brain
    Charlie: Ooh it's such a shame
    We don't talk anymore
    We don't talk anymore
    We don't talk anymore
    Like we used to do
    We don't laugh anymore
    What was all of it for ?
    We don't talk anymore
    Like we used to do
    We don't talk anymore
    The way i did before
    We don't talk anymore
    Ooh Woo S: Ooh it's such a shame
    Chalie: We don't talk anymore '''
    news=news.lower()
    for i in ',.? ()"':
    news=news.replace(i,' ')
    word=news
    word=word.split(' ')
    word.sort()
    zd=set(word)
    di={}
    for i in zd:
    di[i]=word.count(i)
    print(i,di[i])

  • 相关阅读:
    SQL对Xml字段的操作
    五种常见的ASP.NET安全缺陷
    EntityFramework中常用的数据删除方式
    002_ASP.NET 换主题
    001_ASP.NET MVC 实用教程 论坛项目 北盟网校 原创视频教程
    LINQ to Entities 比较日期
    windows10多桌面创建 切换 和分屏
    winform的combox下拉框绑定数据源
    C# 怎么让winform程序中的输入文本框保留上次的输入
    dos 批量重命名 bat
  • 原文地址:https://www.cnblogs.com/zheng01/p/7573909.html
Copyright © 2011-2022 走看看