zoukankan      html  css  js  c++  java
  • 综合练习:词频统计

    str = '''I can swear I can joke
    I say what's on my mind
    If I drink if I smoke
    I keep up with the guys
    And you see me holding up my middlefinger to the world
    F**k your ribbons and your pearls pearls
    'Cause I'm not just a pretty girl
    I'm more than just a picture
    I'm a daughter and a sister
    Sometimes it's hard for me to show
    That I'm more than just a rumor
    Or a song on your computer
    There's more to me than people know
    Some days I'm broke some days I'm rich
    Some days I'm nice some days I can be a bitch
    Some days I'm strong some days I quit
    I don't let it show but I've been through some shit
    I can swear I can joke
    I say what's on my mind
    If I drink if I smoke
    I keep up with the guys
    And you see me holding up my middlefinger to the world
    F**k your ribbons and your pearls
    'Cause I'm not just a pretty girl
    I'm more than just a number
    I'm a hater I'm a lover
    Sometimes it's hard for me to show
    That I'm more than just a title
    Or a comment going viral
    There's more to me than people know
    Some days I'm broke some days I'm rich
    Some days I'm nice some days I can be a bitch
    Some days I'm strong some days I quit
    I don't let it show
    But I've been through some shit
    I can swear I can joke
    I say what's on my mind
    If I drink if I smoke
    I keep up with the guys
    And you see me holding up my middlefinger to the world
    F**k your ribbons and your pearls
    'Cause I'm not just a pretty girl
    I'm not just a pretty girl
    I'm not just a pretty girl
    No I'm not just a pretty girl
    I can swear I can joke
    I say what's on my mind
    If I drink if I smoke
    I keep up with the guys
    And you see me holding up my middlefinger to the world
    F**k your ribbons and your pearls
    'Cause I'm not just a pretty girl
    I'm not just a pretty girl
    I'm not just a pretty girl
    No I'm not just a pretty girl
    I'm not just a pretty girl'''
    print(str.lower())
    
    sep ='''.,;'!'''
    for c in sep:
        str=(str.replace(c,' '))
    print(str)
    
    
    wordList = str.lower().split()
    
    zd={}
    zd1=set(wordList)
    for w in zd1:
        zd[w] = wordList.count(w)
    print(zd)
    
    
    dictList = list(zd.items())
    dictList.sort(key=lambda x:x[1],reverse=True)
    for w in dictList:
        print(w)

    f = open('11.txt','r')
    text = f.read()
    f.close()
    print(text)

  • 相关阅读:
    visual basic VB.NET实例系列教程第三节(常用循环结构之乘法表与数列)
    visual basic VB.NET实例系列教程第二节(好玩又有趣的龟兔赛跑程序)
    visual basic VB.NET实例系列教程第一节(简单实用抽奖程序)
    对DevSecOps的一点认识
    轻便的一句话反弹shell语句
    ActiveMQ 反序列化漏洞(CVE-2015-5254)复现
    《信息安全风险管理》梗概
    微信服务商分账功能开发(PHP)
    哈夫曼编码—文件的压缩与解压(Java)
    哈夫曼编码—数据压缩与解压(Java)
  • 原文地址:https://www.cnblogs.com/ming-z/p/8649534.html
Copyright © 2011-2022 走看看