英文词频统计:
strkey = '''hide and seek it wants to play again like a detective,I won't let it get away it's constan-ly costuming with loads of fake I will strip search if I have to no I'm not afraid to know it no no no I am so determined to chase after what's hidden and seize this day this moment wanna know ENTER KEY to accelerate wanna go ignition turned on it's about the time to drive to truth wanna seize stranger than any movies wanna see ignorance-is not bliss they say that truth will out can't keep on hiding there's no turning back now I'm gonna go on I'm gonna go get what I want myst-is covering my periferal vision but my determination is mind blowing it's so britant I won't be a bit timid it can trick you and there won't be any treat no I'm not afraid to find out no no no so eager so hungry to seek out secret can you conceal it? when I am after you wanna know ENTER WORDS to activate wanna go one more piece to go it's about the time to fill it in wanna seize stranger than any novels wanna see ignorance-is not bliss they say that truth will out can't keep on running there's no turning back now I'm gonna go on I'm gonna go get what I need I wanna know even it may hurt even it brings pain within my mind's determined I need to know even it may kill even it may change me ready to face truth wanna know ENTER KEY to accelerate wanna go ignition turned on it's about the time to drive to truth wanna seize stranger than any movies wanna see ignorance-is not bliss they say that truth will out I wanna go on and gonna keep it "ON" wanna know ENTER WORDS to activate wanna go one more piece to go it's about the time to fill it in wanna seize stranger than any novels wanna see ignorance is not bliss they say that truth will out can't keep on running there's no turning back now I'm gonna go on I'm gonna go get what I need''' strList = strkey.split() print(strList) strSet=set(strList) for word in strSet: print(word,strList.count(word))

输出

 

总结列表,元组,字典,集合的联系与区别。

列表,元组,字典,集合的遍历。

s=[1,2,5,6,7,3,5]
s=set(s)
print(s)

s.add(7)
print(s)

s.remove(6)
print(s)

s1=set([1,2,3])
s2=set([2,3,4])
print(s1&s2)
print(s1|s2)
print(s1-s2)

输出