python如何统计出txt文件有多少行内容?

filename = “F:\python工程\python02\wordcount.txt”
myfile = open(filename)
lines = len(myfile.readlines())
print(“There are %d lines in %s” % (lines, filename))

发布了56 篇原创文章 · 获赞 561 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/CZXY18ji/article/details/101634279