代码如下: #Python-生成一定范围的随机小数 import random A=0 B=1#小数的范围A ~ B a=random.uniform(A,B) C=2#随机数的精度round(数值,精度) print(round(a,C)) 结果如下: