更新时间:2023-11-14 09:38:40
不要那样做 - 将响应视为字符串,并尝试通过字符串替换来获取数据.
Do not do that - treat the response as a string, and try to get you data out through string replace.
响应是一个对象 - 一个元组列表,它实际上是这样的:
The response is an object - a list of tuples, it actually looks like this:
[('ABC',),]
列表中的每个元组都是一个响应行;元组的每个成员都是该行中的一列.
Every tuple in the list is a response row; every member of the tuple is a column in that row.
要获得第一行的第一列,您只需寻址它们(它们的索引从 0 开始):
To get the first column of the first row, you just address them (their indices start from 0):
${value}= Set Variable ${the response object}[0][0]
例如,如果查询返回 3 行,每行 2 列:
If for example the query returnes 3 rows, each with 2 columns:
[('ABC', 'DEF'), ('GHI', 'JKL'), ('MNO', 'PQR')]
,你会得到第三行(索引:2)第二列(索引:1) - 字符串'PQR' - 用这个:
, you'd get the 3rd row's (index: 2) 2nd column (index: 1) - the string 'PQR' - with this:
${value}= Set Variable ${the response object}[2][1]
现在我希望你明白为什么使用字符串替换(在二维列表的字符串表示上)不是一个好主意.
Now I hope you understand why using string replace (over the string representation of a two-dimensional list) is not a good idea.