#project login.py
def login():
username = input()
password = input()
#did some stuff!
#now a new project...
#project access.py
from login import login
if login.username=='ABC' and login.password=='XYZ':
#Cool...gained access!
我的问题是我无法获取如何访问这些局部变量... 除了使用用户名和密码登录的参数之外还有其他方法吗?
答案 0 :(得分:0)
#project login.py
def login():
username = input()
password = input()
#did some stuff!
return username, password
#now a new project...
#project access.py
from login import login
username, password = login()
if username=='ABC' and password=='XYZ':
#Cool...gained access!
您需要在access.py代码中提供结果