函数: example.strip()分离此行的单词 sum()函数的第一个参数是一个列表(list),第二个参数可以直接省去 python风格的代码只要一行: Python sum([len(line.split()) for line in open("C:\\Users\\dell\\Desktop\\123.txt", 'r')]) 1 sum([len(line.split()) for line in open("C:\\Users\\dell\\Desktop\\123.txt", 'r')]) # Python 上一页 文章 Python抓取网页图片 下一页 文章 n阶行列式计算Python和C语言实现 相关文章 Python单下划线与双下划线 2018-03-27 NLTK在python中对文字所表达的情感预测 2017-12-15 Python3 OpenCV入门 2018-08-19 英文字母信息熵与冗余度计算Python实现 2018-05-09