|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
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
|
|||
|
|||
|
writing a list to a file
How do I write a list to a file, becuase I seem to not be able to do it?
|
|
#2
|
|||
|
|||
|
NOTE: Be sure that the data in the list are strings, or make sure that you are writing strings to the file at least.
Here's an example: ============================ # Create a file object and open file # create an empty list # populate the list with numbers ranging 1..10 # convert number in list to strings # write the list to a file # close the file #!/usr/bin/env python myfile = open('myfile', 'w') mylist = [] for x in range(1,11): mylist.append(x) mylist = map(lambda(x): str(x), mylist) myfile.writelines(mylist) myfile.close() ================================= |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > writing a list to a file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|