Python 可以生成具有给定条件的所有可能零件号的列表吗?

发布于 2025-01-15 04:59:32 字数 313 浏览 0 评论 0原文

我是Python新手。就像真正的新事物一样,只是冒险是否可以在我的工作中使用这种语言。

Python 可以从此列表中生成所有可能的零件号吗?

条件:

  1. 角色已订购

可以有ERJ3RBD1002V,但不能有3RERJBD1002V。

太感谢了。

零件编号

I am new to Python. As in really new, just venturing if I can use this language in my work.

Can Python generate all the possible part numbers from this list?

Condition:

  1. Characters are ordered

It can have ERJ3RBD1002V, but not 3RERJBD1002V.

Thank you so much.

PartNumbers

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

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

发布评论

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

评论(1

寂寞花火° 2025-01-22 04:59:32

是的,可以,但电阻值部分(8、9、10、11)除外,因为这些可以是完整的值列表,并且您提供的链接未列出它们。

这是一个简单的代码来做到这一点。它将把RRRR放入电阻值部分。如果您有电阻值列表,只需将它们添加到列表 R 中,它将使用它们来创建组合:

B = ['1R','2R','3R','6R']
C = ['H','B','K', 'E']
R = ['RRRR']
V = {'1R': 'C', '2R': 'x', '3R': 'V', '6R': 'V'}

for bi in B:
    for ci in C:
        for ri in R:
            print ('ERJ '+ bi + ' ' + ci + ' D ' + ri + ' ' + V[bi])

为了清楚起见,我在各部分之间添加了额外的空格,但如果您愿意,可以删除它们

Yes it can, except for the resistance values part (8,9,10,11) since those can be a whole list of values and the link you provided doesn't list them.

Here is a simple code to do it. It will put RRRR into the resistance value part. If you have a list of resistance values, just add them to list R and it will use those to create the combinations:

B = ['1R','2R','3R','6R']
C = ['H','B','K', 'E']
R = ['RRRR']
V = {'1R': 'C', '2R': 'x', '3R': 'V', '6R': 'V'}

for bi in B:
    for ci in C:
        for ri in R:
            print ('ERJ '+ bi + ' ' + ci + ' D ' + ri + ' ' + V[bi])

I put in extra spaces between sections for clarity but you can remove them if you like

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