pyquery CSS选择器父级元素

html = '''
class="wrap">
"container">
''' from pyquery import PyQuery as pq doc = pq(html) items = doc('.list') parents = items.parents() print(type(parents)) print(parents) ''' 输出结果:<class 'pyquery.pyquery.PyQuery'>
class="wrap">
"container">
"container">
''' html = '''
class="wrap">
"container">
''' from pyquery import PyQuery as pq doc = pq(html) items = doc('.list') parent = items.parents('.wrap') print(parent) ''' 输出元素:
class="wrap">
"container">
'''

 

转载于:https://www.cnblogs.com/liangliangzz/p/10273218.html

你可能感兴趣的:(pyquery CSS选择器父级元素)