读取文件时出错

时间:2017-09-10 18:19:00

标签: python-2.7

在尝试创建登录工作程序时,我遇到了一个简单但令人困惑的错误 通过python。

这是我得到的错误。

Traceback (most recent call last):
  File "stratixlogin.py", line 87, in <module>
    main()
  File "stratixlogin.py", line 78, in main
    login_worker()
  File "stratixlogin.py", line 51, in login_worker
    data = f.read()
ValueError: Mixing iteration and read methods would lose datanter code

以下是发生错误的地方:

with open("global_users.txt", "r") as f:
    for line in f:
        data = f.read()
        if data == username_ask:
            print(G+"Success!")

            password_ask = raw_input(O+"Password:"+W+" ")

            with open("global_passwords.txt", "r") as f:
                for line in f:
                    data = f.read()
                    if data == password_ask:
                        print(G+"Success!")

                    else:
                        print(R+"Incorrect Password!")

        else:
            print(R+"No Users Found!")

我不确定这里的错误是什么,但我对如何解决这个问题感到困惑。任何想法?

1 个答案:

答案 0 :(得分:0)

您无法混合遍历文件的行( create or Replace PROCEDURE ussd_100(INSHENASEHG IN VARCHAR2, outSHENASEHP out varchar2, outamt out number) IS Begin Select a_SHENASEHP,nvl(a_amtkol,0)-nvl(a_cred,0) InTo outSHENASEHP,outamt From A_ghabz Where A_SHENASEHG=INSHENASEHG AND A_YEAR=95 AND A_ghabz=1; End ; / Commit; Show Errors; 循环)和 public ActionResult SearchEshtrak(string A_SHENASEHG) { return db.USSD_100(A_SHENASEHG).ToString(); }
这就足够了:

for