函数: 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的psutil模块监控内存代码 2017-10-18 基于LDA的文本主题聚类Python实现 2020-02-24 Python刷访问量GUI程序 2018-02-122 评论 FR算法(Fruchterman-Reingold)Python实现 2020-04-12