a = {}
if type(a) == dict:
#read using dictionary keys.
else:
#treat it as a list
如何将python代码迁移到机器人框架。我试过这个,
${type_obj}= Evaluate type(${a})
${type_bool}= Evaluate ${type_obj} == dict
Run Keyword If ${type_bool}==1 DictHandler
Run Keyword If ${type_bool}==0 ListHandler
但它刚刚因语法错误而崩溃,
Evaluating expression '<type 'dict'> == dict' failed: SyntaxError: invalid syntax (<string>, line 1)
问题是,机器人将python的dict
关键字视为字符串。那么,我如何在机器人内检查变量的类型?
答案 0 :(得分:0)
${type_obj}= Evaluate type(${a})
Run Keyword If 'dict' in '${type_obj}' DictHandler
... ELSE ListHandler