Python 统计文件相同字段次数

来源:互联网 发布:网络贷被全面叫停政策 编辑:程序博客网 时间:2024/06/05 01:56
mylist=["a","a","b","c","c","c","d","d","d","d",'e']length=len(mylist)#求长度print("length",length)i=0while i<length:#遍历列表    times=1 #次数    passwordstr=mylist[i]#记录密码    while  i+1<=length-1  and mylist[i]==mylist[i+1]:#i+1存在,        times+=1  #次数+1        i+=1      #i前进    print(times,passwordstr)    i+=1

原创粉丝点击