我是pyparsing的新手。
如何將類pyparsing.ParseResults的實例轉換回html字符串。將pyparsing.ParseResults轉換回html字符串
ex。
>>> type(gcdata)
<type 'unicode'>
>>> pat
{<"div"> SkipTo:(</"div">) </"div">}
>>> type(pat)
<class 'pyparsing.And'>
>>>
>>> l = pat.searchString(gcdata )
>>> l[0]
(['div', ([u'class', u'shoveler'], {}), ([u'id', u'purchaseShvl'], {}), False, u'<div class="shoveler-heading">\n <p>Customers Who Bought This Item Also Bought</p>\n \n', '</div>'], {'startDiv': [((['div', ([u'class', u'shoveler'], {}), ([u'id', u'purchaseShvl'], {}), False], {u'class': [(u'shoveler', 1)], 'empty': [(False, 3)], u'id': [(u'purchaseShvl', 2)]}), 0)], 'endDiv': [('</div>', 5)], u'class': [(u'shoveler', 1)], 'empty': [(False, 3)], u'id': [(u'purchaseShvl', 2)]})
>>>
>>> type(l[0])
<class 'pyparsing.ParseResults'>
>>>
>>> divhtml = foo (l[0])
所以,我需要這個功能FOO。
有什麼建議嗎?