python - 我想在 Python 的 if 语句中有多个值
问题描述
我不完全确定该怎么做。感谢您提供任何帮助,对于新手问题感到抱歉。
if input_num != 8 or 16 or 32 or 64 or 128 or 256:
#some function
我认为问题是“或”,我认为这不是正确的方法。
解决方案
您必须每次都重复该语句,如下所示:
if input_num != 8 and input_num != 16 and input_num != 32 and input_num != 64 and input_num != 128 and input_num != 256:
推荐阅读
- java - 如何使用 Java 驱动程序对 mongo db 中嵌套 HashMap 的值求和
- python - 当您知道 URL 的一部分时,在 Python 中抓取图像及其替代文本
- django - Django REST 在 DELETE 方法上给出 403 禁止,但不是 POST
- node.js - 如何在 mongoDB 中减去 2 个操作?
- loopback4 - 用于测试的环回更改存储库数据源
- sql-server - 日期范围之间的 7 天平均值
- javascript - 如何将每个 scss 文件编译到自己的文件夹中而不将它们合并到一个文件夹中?
- javascript - 404 错误,在 webcomponent 单元测试期间找不到 html
- java - 从 Google 更改后,当我在 Google Play 上发布应用程序时,许多设备不支持 xWalkWebView 64 位
- c# - 图像比较程序(需要优化)