我正在与亚马逊博托合作,我有2个名单.列表1包含实例对象.列表2包含InstanceInfo对象.两个对象都有一个名为id的属性.我需要获取InstanceInfo列表中存在id的Instance对象列表.
l1 = [Instance:i-04072534, Instance:i-06072536, Instance:i-08072538, Instance:i-0a07253a, Instance:i-e68fa1d6, Instance:i-e88fa1d8, Instance:i-ea8fa1da, Instance:i-ec8fa1dc]
l2 = [InstanceInfo:i-ec8fa1dc, InstanceInfo:i-ea8fa1da, InstanceInfo:i-e88fa1d8, InstanceInfo:i-e68fa1d6]
Run Code Online (Sandbox Code Playgroud)
通缉结果:
l3 = [Instance:i-ec8fa1dc, Instance:i-ea8fa1da, Instance:i-e88fa1d8, Instance:i-e68fa1d6]
Run Code Online (Sandbox Code Playgroud)
现在我有它通过:
l3= []
for a in l1
for b in l2:
if a.id == b.id:
l3.append(a)
Run Code Online (Sandbox Code Playgroud)
但是,有人告诉我,我应该使用set intersection替换它.我一直在看例子,看起来很简单.但我没有看到任何使用对象的示例.
我已经玩了一段时间,理论上我可以看到它的工作,但可能有一些我可能不知道的'高级'语法.我还在学习python.
真的很快(但很复杂?)的问题.
我有这个:
<select multiple="multiple" id="id_products" class="selectmultiple" name="products">
<option value="3243">testproductP (3243)</option>
<option value="3244">testproductQ (3244)</option>
</select>
Run Code Online (Sandbox Code Playgroud)
我需要使用selenium进行机器人框架复制,我选择了一个选项.但是我找不到像"选择选项"这样的关键字.所以我尝试使用带有指向该选项的xpath的"Click Element".
Click Element xpath=//select[@name="products"]/option[@value=3244]
Run Code Online (Sandbox Code Playgroud)
但是,这会导致错误测试失败:"超时:超时"
xpath返回正确的元素,但不知怎的,它超时了.也许Click Element不应该像这样使用,但我找不到更好的关键字.
知道发生了什么事吗?