英文词频统计预备,组合数据类型练习

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的方式相同,除了整个元素集是用小括号包围的而不是方括号。

转载于:https://www.cnblogs.com/D0204/p/7565134.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值