组合数据类型练习、英语词频统计
?
總結列表,元組,字典,集合的聯系與區別。 w=list('154896') e=tuple('564255') t=dict(zip(w,e)) u=set([5,3,8,8,6,1]) for i in w:print(i) for i in e:print(i) for i in t:print(i,t[i]) for i in u:print(i)
| ? | 列表 | 元組 | 字典 | 集合 |
| 可否讀寫 | 可讀寫 | 只讀 | 可讀寫 | 可讀寫 |
| 可否重復 | 是 | 是 | 是 | 否 |
| 存儲方式 | 值 | 值 | 鍵值對(鍵不可重復) | 鍵(不可重復) |
| 是否有序 | 是 | 是 | 否 | 否 |
| 添加 | append | ? | d[key]=value | add |
| ? | ? | ? | ? | ? |
?
lp='''You hid your skeletons, when I had shown you mine
you woke the devil that I thought you left behind
I saw the evidence the crimson soaking through
ten thousand promises, ten thousand ways to lose...
And you held It all
but you were careless to let it fall
you held it all
and I was by your side
Powerless
I watched you fall apart
and chased you to the end
I'm left an empty mess, that words can not defend
you'll never know what I became
because of you
ten thousand promises, ten thousand ways to lose...
And you held It all
but you were careless to let it fall'''
less=lp.lower()
print(less)
for i in ",...'":
lp=less.replace(i," ")
print(lp)
power=lp.split()
print(power)
dic={}
for i in power:
dic[i]= power.count(i)
lp=list(dic.items())
)
?
?
?
轉載于:https://www.cnblogs.com/yin-yeah/p/7596004.html
總結
以上是生活随笔為你收集整理的组合数据类型练习、英语词频统计的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: hadoop集群
- 下一篇: Microsoft SQL Server