简体   繁体   中英

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.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

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM