python - While 循环(非常简单)
问题描述
我正在处理下面的代码,我想要or ,但它一直在 while 循环中运行temp
。1
2
temp = input("1 for yes/2 for no")
while (temp!="1" or temp!="2"):
print("please input 1 or 2")
temp = input("1 for yes/2 for no")
print(temp)
解决方案
改变这个:
while temp!="1" or temp!="2":
对此:
while temp!="1" and temp!="2":
推荐阅读
- amazon-cognito - 将 Github 身份提供商添加到 AWS Cognito
- php - 使用 php 在另一个页面上使用 header() 函数提交 jquery 后重定向页面
- security - 使用动态用户进行 RabbitMQ 用户身份验证
- xamarin - Xamarin 表单 GoogleAds 显示外壳底部
- python-3.x - 在 Python 3 中将 16 位十六进制字符串转换为双精度值
- c# - Moq - 模拟 DbSet
.AddAsync 不引发任何调用 - python - mypy 找不到黑色的类型提示
- html - 如何在标签旁边的输入集中在具有多个标签的表单中并在css中输入时更改标签中文本的颜色
- c++ - GRPC C++ 异步服务器如何区分 WritesDone 和断开的连接
- javascript - 用于跟踪在 Qualtrics 中收听的音频量的 Javascript