Reading in strings -> numbers ??

Bruce Dodson bruce_dodson.nospam at bigfoot.com
Fri Apr 28 21:15:21 EDT 2000


The syntax is not equivalent in the same sense as printf vs. scanf, but the
re module will you to parse out substrings from whatever text file format
you are trying to read, and then eval() can be used on the components of the
result, to turn the "fields" that are numeric strings into Python numbers.

Bruce


Louis M. Pecora wrote in message
<280420001700308281%pecora at anvil.nrl.navy.mil>...
>Is there a Python "read-partner" for the write(string) function, e.g.,
>
>fileobject.write(" %e %e %d" % (1.2, -3.5, 10))





More information about the Python-list mailing list