小伍的游乐场 › 文章 › code › 文章 Python3 从入门到实践 第十章 习题10-10 A-A+游于艺2018-11-10 22:03:05734次浏览Python #coding:gbk filename = 'pg58251.txt' with open(filename) as obj: line = obj.read()#不是为了赋值而赋值,是为了read()而赋值 print(line.count('the'))#count() 是查询使用了多少个 the print(line.lower().count('the'))#查询之前.lower()是转化为小写之后再比对 #以上文本文件来自 Gutenberg 无版权读物网站 发表评论点击这里取消回复。 姓名 (必填) 邮箱(不会被公开) (必填) 站点 表情 [pem]