码迷,mamicode.com
首页 > 其他好文 > 详细

给vrtv

时间:2018-06-20 22:36:35      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:count   ssl   ssd   read   split   file   close   sum   ext   

#1.
SummertimeSadnessFile = open(SummertimeSadness.txt,mode="r",encoding=utf-8)
SummertimeSadnessText = SummertimeSadnessFile.read()
SummertimeSadnessFile.close()
print(SummertimeSadnessText)

#2.
replaceList = [,,.,"",\n]
for c in replaceList:
    SummertimeSadnessText = SummertimeSadnessText.replace(c, )
print(SummertimeSadnessText)

#3.
print(SummertimeSadnessText.split( ))
SummertimeSadnessList = SummertimeSadnessText.split( )

#4.
SummertimeSadnessSet = set(SummertimeSadnessList)
print(SummertimeSadnessSet)

SummertimeSadnessDict = {}
for word in SummertimeSadnessSet:
    SummertimeSadnessDict[word] = SummertimeSadnessList.count(word)

print(SummertimeSadnessDict)
for d in SummertimeSadnessDict:
    print(d,SummertimeSadnessDict[d])

 

给vrtv

标签:count   ssl   ssd   read   split   file   close   sum   ext   

原文地址:https://www.cnblogs.com/csn123/p/9206175.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!