Monday, April 30, 2012

Python: How can add words to a list?

Okay, the Title is a bit vague, but what I'm trying to do is download data online, parse it and then put the parsed 'data' into an excel file.

I'm getting stuck in trying to put the data into a vector or list. Note that, the data can be either words or numbers. Also, I the length of the data is unknown. I tried the code below:

class MyHTMLParser(HTMLParser):
def handle_data(self, data):

parser = MyHTMLParser()
'<body><h1>Parse me!</h1></body></html>')


Traceback (most recent call last):
File "<pyshell#34>", line 1, in <module>
NameError: name 'd' is not defined

I looked around the forum for an answer, but didn't seem to encounter anything. I am a beginner, so may I'm missing something basic? Thanks, for the help...

No comments:

Post a Comment