
May 21st, 2002, 11:18 PM
|
|
Junior Member
|
|
Join Date: May 2002
Location: Atlanta, Ga
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
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()
=================================
|