Home > other >  [great god please enter] call customised module error problem!!
[great god please enter] call customised module error problem!!

Time:09-24

My custom a login function in local call didn't ask questions, but can appear in other modules call error: TypeError: string indices must be integers
The called module:
 
Def the login () :
While True:
Log_user=input (" [bank] please enter the authenticated user:)
Log_passwd=input (" [bank] enter the password for authentication: ")
F=open (" base ", "r", encoding="utf-8")
Try:
The line=f.r eadline ()
Data_dict=eval (STR (line). Strip ())
Except SyntaxError as err:
F. lose ()
Break
If log_user data_dict in:
If log_passwd==data_dict [log_user] [" password "] :
Print (" [bank] login successful!" )
F. lose ()
Return True
The else:
Print (" [bank] user name or password error!" )
The continue
The else:
Print (" [bank] user name or password error!" )
The continue


Read the content of the files
 
{" jack ": {" password" : "123", "monary" : 10000}}


Call module:
 
The import of OS, sys
BASE_DIR=OS. The path. The dirname (OS) path) dirname (OS) path) abspath (__file__)))
Sys. Path. Append (BASE_DIR)

The from bank import bank_def

Bank_def. The login ()


This problem want to half a day don't understand what's going on, a great god guidance, please!!!
  • Related