摘要:
import random()testlist = [1,3,4,5]a,b = 1,5random().random()() 生成0至1之间的随机浮点数,结果大于等于0.0,小于1.0random.randint(a,b) 生成1至5之间的随机整数,结果大于等于1,小于等于5,a必须小于等于brandom.choice(testlist)从testlist中随机挑选一个数,也可以是元组、字符串 阅读全文
摘要:
%s str%d 整数%f 浮点数print('$%.03f' % 30.1777)>>>$30.178 #四舍五入print( '%-5s %s %10s' % ('John','every','man') )>>>John every man 阅读全文