FuckWindowsError 2018-12-03 04:18 采纳率: 50%
浏览 2825
已采纳

关于PYTHON使用with open配合For读取文件运行至For循环停止执行的疑问?

                with open(self.userList,'r') as f_username:
            UserListCount=len(list(f_username))
            print(UserListCount)
            with open(self.passList,'r') as f_password :
                for name in f_username:
**************************请问以下代码为何不会执行?**********************
                    if Finished == 1 or UserBreak ==1:  
                        break
                    UserTryCount=UserTryCount+1
                    print("正在pojie"+name+"进度表:"+str(UserTryCount)+"/"+UserListCount)
                    for key in f_password:
                        if Finished==1 or UserBreak==1 or PassBreak ==1:
                            break
                        if AllCount % 10 == 0:
                            print("已尝试"+str(AllCount)+"个")
                        if len(key)<self.MiniLen:
                            continue 
                        try:
                            AllCount=AllCount+1
                            if  self.Login(name,key)==True:
                                self.SuccesList.append(name+FG+key)
                                PassBreak= 1
                            elif Login==False :
                                continue
                            else :
                                UserBreak=1
                        except Exception as e:
                            print("抱歉,发生异常错误"+str(e))
                            continue
        if Finished!=1 and UserBreak!=1:
            print("抱歉,在此字典中并未找到正确的密码")
    except Exception as e:
        print(e)
  • 写回答

1条回答 默认 最新

  • FuckWindowsError 2018-12-03 04:58
    关注

    自己已经解决了。。。。。。。。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?