python-3.x - 有没有办法让 While 函数具有两个条件?
问题描述
当我运行我的代码时,即使我输入 1 或 2,它也会运行。
我已经做过了while a != 1 or 2:
,while a != 1 or a !=2:
a = 0
while a != 1 or a !=2:
a = int(input('Input: '))
print('end')
我想知道在不使用“break”方法的情况下使用两个条件中断的方式。
解决方案
a
不能同时是 1 和 2,所以这是一个无限循环:
while a != 1 or a != 2:
推荐阅读
- reactjs - 反应路由器路径
- react-native - 将 react-native (web) 集成到 Django 中。如何为所有网址添加前缀?
- python - Keras/Tensorflow 从路径列表创建数据集
- django - 自定义静态文件未在 django 项目中加载
- spring - 如何在 Spring Boot 中使用 IPwhitelisting 和 OAuth2?
- recaptcha - 需要帮助查找 reCaptcha 密钥
- python-3.x - 如何使用 Scrapy 过滤搜索结果
- angular - 如果一个模块被多个模块引用,那么最终捆绑包中有多少个模块实例?
- node.js - localhost 的子域不适用于 express-subdomain
- c# - C# 和 PInvoke Winapi 程序挂起