python 统计文件夹中所有python文件的行数之和

import os

count=0
for root,dirs,files in os.walk("C:\python\Lib"):
	for file_name in files:
		if file_name[-3:]==".py":
			file_path=os.path.join(root,file_name)
			with open(file_path,"rb") as fp:
				for line in fp:
					count+=1
		

猜你喜欢

转载自blog.csdn.net/weixin_44123630/article/details/111597844