如何使用Robot Framework在列表中找到最低值?

Man*_*mar 4 python robotframework

我正在尝试使用Robot Framework在列表中找到最低值.我在python中编写了自定义关键字,如下所示:

 def Minimum_Value_from_list(self, list_):

    return min(list_)
Run Code Online (Sandbox Code Playgroud)

我已经执行了以下RF脚本

Find lowest value
    @{list}=    Create List     3    5    9   16    31    42    66     75
    Log List    ${list}
    ${LowValue}=    Minimum_Value_from_list    ${list}
Run Code Online (Sandbox Code Playgroud)

它将输出(最小值)显示为16,这是不正确的.

任何输入/建议都有助于获得正确的输出

Bry*_*ley 8

默认情况下,robot会将值作为字符串传递.在获得最小值之前,您需要将它们转换为整数.

如果你可以安全地假设所有值都是整数,那么一种方法就是使用列表理解:

return min([int(x) for x in list_])
Run Code Online (Sandbox Code Playgroud)