How can I assign names to some numbers to feed them into a random number generator as variables
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.00119开发者_开发技巧35729005
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
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()
精彩评论