简体   繁体   English

如何使用python在机器人框架中检查字典是否为空

[英]How to check if the dictionary is empty or not in robot framework using python

I tried to check the given dictionary is empty or not in robot framework but it is giving an error saying syntax error. 我试图检查给定的词典在机器人框架中是否为空,但给出语法错误。 Here is the following example of how I compared it: 以下是我进行比较的以下示例:

Run Keyword If '${source_list_data}'=='[]' FAIL and the error which i got is: 运行关键字如果'$ {source_list_data}'=='[]'失败,我得到的错误是:

Evaluating expression ''[{'data':'value'}]'=='[]'' failed: SyntaxError: invalid syntax (, line 1) 评估表达式“ [[{'data':'value'}]'=='[]”失败:SyntaxError:语法无效(第1行)

Your syntax works for me. 您的语法对我有用。 Strange it does not work for you. 奇怪,它对您不起作用。

Here is another way to achieve it using Get Length : 这是使用Get Length实现它的另一种方法:

*** Settings ***
Library  Collections

*** Test Cases ***
dict_empty
    ${source_list_data} =  create dictionary
    ${length} =  Get Length  ${source_list_data}
    Run Keyword If  ${length} == 0  log to console  Empty Dict

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM