如何检查IF语句的多种可能的组合?

发布于 2025-02-01 11:57:53 字数 246 浏览 1 评论 0原文

因此,我有20个条件,我试图检查不同的组合。

例如:

1和2或3 1或2或3和4 4和5或2 4和5和2或9 Ect ....

我想弄清楚我该怎么办。尽管我可能会使用Swich Case,但是在这样的情况下,我不确定如何做到这一点。

需要检查所有可能的选项,但我想尝试至少15-20“和“”或“组合”。

会喜欢这里的一些建议! :)

So I have 20 conditions and im trying to check different combinations.

for example:

1 and 2 or 3
1 or 2 or 3 and 4
4 and 5 or 2
4 and 5 and 2 or 9
ect....

I'm trying to figure out what should I do. I though maybe use a swich case but I'm not really sure how to do that in a case like that with so many options.

I dont need to check All the possible options but i would like to try at least 15-20 "and " " or" combinations.

would love some advice here!
:)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风轻花落早 2025-02-08 11:57:53

这应该为您提供所有组合:

a = '1234567890'
b = list(a)

for c in b:
    for d in b:
        print(c+d)

This should give you all combinations:

a = '1234567890'
b = list(a)

for c in b:
    for d in b:
        print(c+d)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文