python - Calling the second function in a "while" loop
问题描述
I'm on my early python self learning path and somehow I can't get the code to execute def cadastro() whenever 1 is imputed. Can you please assist. Valuable contributions have been shared with me on this forum which I'm greatly appreciative of, however I remain stuck with this code.
lista_de_usuarios = {}
print ('BEM VINDO AO BCI')
print("PARA CADASTRO PRESSIONE 1 E 2 PARA LOGIN")
while True:
opcao_1 = input()
if opcao_1 == '':
print ('NADA FOI SELECIONADO, ADEUS')
break
elif opcao_1 == 2:
acesso()
elif opcao_1 == 1:
cadastro()
def acesso():
print ('Insira o seu usuário')
user = input()
print ('insira a sua palávra chave')
password = input()
if user in lista_de_usuarios:
if lista_de_usuarios[user] == password:
print ('ACESSO LIVRE')
else:
print ('A senha digitada está incorrecta')
else:
print('Este usuário não consta em nossa base de dados')
acesso()
def cadastro():
print ('Insira o seu nome')
nome = input()
print ('insira a sua idade')
idade = input()
lista_de_usuarios[nome]=idade
cadastro()
解决方案
你忘了"
在你的数字之前添加。因为您要求用户输入并添加str()
,所以他们只能输出一个字符串。
elif opcao_1 == "1":
acesso()
elif opcao_1 == "2":
cadastro()
推荐阅读
- spring - 将 SQL 文本数组映射到 Spring 数据 JPA 中的 Java 字符串列表
- vagrant - vagrant unsync 文件夹不适用于自定义目录
- json - 如何将 struct 转换为 json 没有用于 restAPI 的密钥
- microsoft-graph-api - 更新日历邮箱的 Microsoft Graph 订阅时出现“未找到”错误
- ios - 如何在swift 3中做UIView Intrective Animation?
- spring-boot - 如何通过命令行参数覆盖 application.properties 以指定数据源属性
- javascript - 如何使用 lodash 从以下输入中获取此类输出
- c++ - std::getline 在代码中使用了两次,跳到第二个 getline
- java - 编码帮助(If 语句)
- python - 在 asyncio 模块中完成一个 task_list 后,如何提交另一个 task_list?