String Fomat Conversion

Dennis Benzinger Dennis.Benzinger at gmx.net
Thu Jan 27 03:35:06 EST 2005


mcg wrote:
> Investigating python day 1:
> 
> Data in file:
> x   y
> 1   2
> 3   4
> 5   6
> 
> 
> Want to read file into an array of pairs.
> 
> in c: scanf("%d %d",&x,&y)---store x y in array, loop.
> 
> How do I do this in python??
> In the actual application, the pairs are floating pt i.e. -1.003
> 

Either do what the other posters wrote, or if you really like scanf
try the following Python module:

Scanf --- a pure Python scanf-like module
http://hkn.eecs.berkeley.edu/~dyoo/python/scanf/

Bye,
Dennis



More information about the Python-list mailing list