嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元微信扫码支付:2 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
统计txt文件所有行数的和,适合几十兆几百兆且上百上千个文件手算不过来时使用
import time
import os
def getcount():
dirpath=input("请输入要计算的文件夹如(d:\\user):")
# dirpath=os.path.dirname(os.path.abspath(__file__)) "\\ipbak3"
iptxtlist=os.listdir(dirpath)
ipstrs1=[]
filecounts=len(iptxtlist)
print(filecounts)
counts=0
for j in range(0,filecounts):
filepaths=dirpath "\\" iptxtlist[j]
with open(filepaths, 'r') as f:
try:
for line in f.readlines():
counts=counts 1
except Exception:
counts=counts 1
print(counts)
print(counts)
input("按任意键继续")
if __name__ == '__main__':
getcount()