0
的实例之间支持我必须安装在Windows 7版本的Python 3.6.2,我得到以下错误:“>”不“方法,包装”和“廉政”
TypeError: '>' not supported between instances of 'method-wrapper' and 'int'
哪有我解决这个问题?
# create a subclass and override the handler methods
class MyHTMLParser(HTMLParser):
# function to handle an opening tag in the doc
# this will be called when the closing ">" of the tag is reached
def handle_starttag(self, tag, attrs):
pos = self.getpos() # returns a tuple indication line and character
print ("At line: ", pos[0], " position ", pos[1])
if attrs. __len__ > 0:
print ("\tAttributes: ")
for a in attrs:
print ("\t", a[0], "=", a[1])
它工作。非常感谢,特别是对于更简单的方法:) – Sparky