首页 > 其他 > 详细

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

时间:2017-09-20 21:47:04      阅读:255      评论:0      收藏:0      [点我收藏+]

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

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

原文:http://www.cnblogs.com/D0204/p/7565134.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!