for line in open(''text.txt''):numlines + = 1 AlexYou''re welcome;-). However, this approach reads all of the file intomemory at once. If you must be able to deal with humungoug files, toobig to fit in memory at once, try something like:numlines = 0for line in open(''text.txt''): numlines += 1Alex 这篇关于如何计算文本文件中的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-08 03:39