Python 列表推导式

列表推导式实现:

for webElement in webElements:

    fields = webElement.find_elements_by_css_selector('span')
    resultlist = [field.text for field in fields]
    print(resultlist)

for循环实现:

for webElement in webElements:
    resutlist = []

    fields = webElement.find_elements_by_css_selector('span')

    for field in fields:
        resutlist.append(field.text)

    print(resutlist)

 

上一篇:CSS——CSS滑动门及其应用(制作微信导航栏) ※


下一篇:输入框提示信息以及显隐效果