|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
need a bit of help with htmllib
import htmllib
import formatter w = formatter.DumbWriter() f = formatter.AbstractFormatter(w) file = open("assign.html") parser = htmllib.HTMLParser(f) parser.feed(open('assign.html').read()) parser.close() ################### I've recently began to learn python, so i need a bit of help. Instead of outputting the text on the screen how can i store it in a string or a text file? |
|
#2
|
|||
|
|||
|
Pass an instance of a file (or file-like) object to the constructor for DumbWriter().
to write to a string you can use a StringIO object, which behaves like a file, but stores the 'file' in memory so that you can extract it later as a string. Dave - The Developers' Coach |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > need a bit of help with htmllib |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|