摘要: 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' 阅读全文
posted @ 2013-01-22 10:04 践道者 阅读(1194) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-01-22 00:11 践道者 阅读(403) 评论(0) 推荐(0) 编辑