摘要:
from cStringIO import StringIOoutput = StringIO()output.write("This goes into the buffer.")print >>output, 'And so does this.' #连接字符串print output.getvalue()output.close()input = StringIO('Inital value for read buffer')print input.read()input.write(' leon-test' 阅读全文
摘要:
import randomfor i in xrange(5): print '%.4f' % random.random(),printfor i in xrange(5): print '%04.3f' % random.uniform(1, 100),printdef uniform(min, max): return min + (max - min) * random.random()for i in xrange(5): print '%04.3f' % uniform(1, 100),print 初始化随机数种子:random.se 阅读全文