拆分后获取变量名称(getting the name of variable after splitting)

编程入门 行业动态 更新时间:2024-10-25 12:18:18
拆分后获取变量名称(getting the name of variable after splitting)

我有这样的场景------

right = some_function (some_value) var idR =right.split('~')[0]; var r =right.split('~')[1]; left = another-func (some_value) var idL = left.split('~')[0]; var l = left.split('~')[1];

需要注意的是,r,l包含数值。 我的目的是我想在r和l之间取最大值,之后我会根据r或l的最大值回到'right'或'left'。

我正在使用math.max()但这不起作用,因为它只返回值,而不是变量的名称。

我怎样才能实现我的目标?

让我提供一些示例输入和输出 - “some_function”返回格式为“id~value”的字符串,其中“id”可以是“1-1”,“2-2”等等,“value”可以是任何数值。 我需要查看更大的“值”并获取其相应的“id”。 请注意,“another_func”以相同的模式返回值

我的代码不仅仅是这两个块,我有八个这样的功能,我必须拿出最大的数字及其相应的ID

I have a scenario like this------

right = some_function (some_value) var idR =right.split('~')[0]; var r =right.split('~')[1]; left = another-func (some_value) var idL = left.split('~')[0]; var l = left.split('~')[1];

point to be noted that r,l contains numeric values. My purpose is that I want to take the maximum between r and l, and after that I will traverse back to 'right' or 'left' according to maximum value of r or l.

I am using math.max() but this is not working as it only returns the value, not the name of variable.

How can I achieve my goal???

Let me provide some sample inputs and outputs-- "some_function" returns a string in the format "id~value" where "id" can be "1-1", "2-2" and so on and "value" can be any numeric value. I need to look at the greater "value" and fetch its corresponding "id". Note that "another_func" returns values in same pattern

MY CODE IS NOT THESE TWO BLOCKS ONLY, I HAVE EIGHT FUNCTIONS LIKE THESE AND I HAVE TO TAKE THE BIGGEST NUMBER AND ITS CORRESPONDING ID

最满意答案

你的问题不是很清楚。

让我们试试这个,所以你有2个数组,其值为r和l,2个数组的变量名为idR和adL。

现在这还不清楚,那些包含变量名的数组是否具有相同的顺序? 相同的价值观? 这种情况可以信任吗?

你显然希望从值数组得到一些最大值,但你没有解释其他数组如何适应图片:)你这样做后,可能我或其他人可以帮助你:)

Your question is not very clear.

Let's try this, so you have 2 arrays with values r and l and 2 arrays with variable names idR and adL.

Now this is what's not clear, do those arrays containing variable names have the same order? the same values? can this condition be trusted?

You clearly want to get some max value from the values arrays that's ok, but you aren't explaining how the other arrays fit on the picture :) After you do, probably me or someone else can help you :)

更多推荐

本文发布于:2023-08-05 13:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1433984.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   名称   splitting   variable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!