Robot Framework 如何获取文本项
Posted
技术标签:
【中文标题】Robot Framework 如何获取文本项【英文标题】:Robot Framework How to Get Text Item 【发布时间】:2021-04-04 13:59:27 【问题描述】:我编写了从字典中提取数据的代码,并希望将信息保留为如下格式。
A = 2018
B = 8
A = 2019
B = 2
A = 2020
B = 3
行数据,我想从下面访问数据点。
[
"A": 2018,
"B": 8,
"C": 7,
"D": 8,
"E": 0.0,
"F": 8,
"G": 8,
"H": 8,
,
"A": 2019,
"B": 2,
"C": 5,
"D": 6,
"E": 0,
"F": 9,
"G": 16,
"H": 5,
,
"A": 2020,
"B": 3,
"C": 8,
"D": 61,
"E": 0,
"F": 2,
"G": 1,
"H": 2,
,
]
请帮我找到解决办法。谢谢
【问题讨论】:
Row data, I want to access the data points from below.
我不知道如何将含义与此联系起来——甚至用 raw 代替 Row
。对于E
,0.0
和0
的含义有区别吗?请注意How do I ask a Good Question?
【参考方案1】:
a = [
"A": 2018,
"B": 8,
"C": 7,
"D": 8,
"E": 0.0,
"F": 8,
"G": 8,
"H": 8,
,
"A": 2019,
"B": 2,
"C": 5,
"D": 6,
"E": 0,
"F": 9,
"G": 16,
"H": 5,
,
"A": 2020,
"B": 3,
"C": 8,
"D": 61,
"E": 0,
"F": 2,
"G": 1,
"H": 2,
,
]
b = ""
for item in a:
b = b + "A:" + str(item["A"]) + "\n" + "B:" + str(item["B"]) + "\n"
print(b)
Output:
A:2018
B:8
A:2019
B:2
A:2020
B:3
【讨论】:
以上是关于Robot Framework 如何获取文本项的主要内容,如果未能解决你的问题,请参考以下文章
Robot Framework - 访客界面 - 如何获取关键字的关键字子项?
Robot Framework XPATH元素的定位(如何获取一个动态或具体的元素)