S
SunX
Question from a newbie. How do you write out a data file of floating
point numbers? file.write only takes strings.
Many thanks.
point numbers? file.write only takes strings.
Many thanks.
SunX said:Question from a newbie. How do you write out a data file of floating
point numbers? file.write only takes strings.
Many thanks.
SunX said:Question from a newbie. How do you write out a data file of floating
point numbers? file.write only takes strings.
Many thanks.
.... f.write(repr(n))somefloats = [1.2, 3.4, 5.7]
f = file("tmp.txt", "w")
for n in somefloats:
.... readfloats.append(float(line))f = file("tmp.txt")
readfloats = []
for line in f:
3.4str(readfloats[1]) '3.4'
print readfloats[1] # uses str() for string conversion
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.