tags:

views:

26

answers:

1

Hi, I need some assistance here.

import urllib2
pen = urllib2.Request("http://silasanio.appspot.com/mean_stdev")
response = urllib2.urlopen(pen)
f = response.read()
print f


-0.0011935729005
0.0313498454115
...............
..............

the numbers above were returned together with some other texts. My problem is I want those numbers as variables to feed a random number generator. That is I want the first number assigned mean and the second assigned standard_deviation. I need assistance on how to do that, please.

Thanks

+1  A: 

If you can avoid making f, you can just use:

lines = response.readlines()
mean = float(lines[0])
stddev = float(lines[1])

If you need f for other purposes, replace the first of these statements with

lines = f.splitlines()
Alex Martelli