英文词频统计预备,组合数据类型练习
Posted 002邓诺斯
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了英文词频统计预备,组合数据类型练习相关的知识,希望对你有一定的参考价值。
1.
read=\'\'\'Zhuang Zhou\'s family was poor. Once, he went to the official who supervised1 rivers to borrow some grain. The official said: "Well, wait until the end of the year when I collect the taxes from the people, then I will lend you 300 gold pieces. All right?"
When Zhuang Zhou heard this, he was so angry that the colow of his face changed. But he told the official this story: When I came here yesterday, on the way I heard a voice calling \'Help!\' I turned my head and saw a small crucian carp in the dried-up carriage ditch2."
I went over and asked: "Little crucian carp, why are you calling for help?"\'\'\'
read=read.lower()
for i in \',.!?\':
read=read.replace(i,\'\')
words=read.split()
print(words)
print(\'he\',words.count(\'he\'))
print(\'i\',words.count(\'i\'))
2.
fen=list(\'1232112\')
print(\'原本:\',fen)
fen.append(\'3\')
print(\'增加‘3’:\',fen)
fen.insert(1,\'1\')
print(\'插入1:\',fen)
fen.pop()
print(\'删除:\',fen)
fen[2]=\'3\'
print(\'修改\',fen)
print(\'第0位是:\',fen[0])
print(\'3的下标是:\',fen.index(\'3\'))
print(\'1的数量:\',fen.count(\'1\'))
print(\'1的数量:\',fen.count(\'3\'))
for i in range(len(fen)):
fen[i]=int(fen[i])
print(fen)
3.
1)list是一个使用方括号括起来的有序元素集合。list可以增删改查
2)Tuple是不可变的list.一是创建了一个tuple就不能以任何方式改变它。定义tuple与定义list的方式相同,除了整个元素集是用小括号包围的而不是方括号。
以上是关于英文词频统计预备,组合数据类型练习的主要内容,如果未能解决你的问题,请参考以下文章