擅长:python、mysql、java
<p>不要<code>print</code>,而是将结果附加到列表中;外循环每次迭代一个新列表:</p>
<pre><code>test = []
results = driver.find_elements_by_css_selector("li.result_content")
for result in results:
# Other code about result.find_element_by_blah_blah
product_feature = result.find_element_by_class_name("prod-feature-icon")
features = []
for each_item in product_feature.find_elements_by_tag_name('img'):
features.append(each_item.get_attribute('src')[34:-4])
test.append(features)
</code></pre>
<p>如果需要,可以打印<code>features</code>,也可以打印<code>test</code>,只是为了查看<code>for</code>循环的每一级发生了什么。你知道吗</p>