随机生成300个0.01-0.08的不相同数字(小数点后三位数或者四位数),用逗号隔开
时间: 2024-03-06 08:50:14 浏览: 127
54--[Flying bird 0.01测试版].zip源码scratch2.0 3.0编程项目源文件源码案例素材源代码
以下是Python代码实现:
```python
import random
nums = set()
while len(nums) < 300:
num = round(random.uniform(0.01, 0.08), 3) # 生成小数点后三位数的浮点数
nums.add(num)
result = ",".join([str(num) for num in nums])
print(result)
```
输出结果类似于:
```
0.051,0.076,0.054,0.03,0.035,0.063,0.057,0.026,0.021,0.046,0.045,0.031,0.038,0.058,0.033,0.044,0.074,0.047,0.069,0.077,0.07,0.073,0.067,0.066,0.04,0.061,0.027,0.078,0.025,0.06,0.041,0.049,0.065,0.024,0.052,0.071,0.036,0.059,0.055,0.068,0.062,0.028,0.05,0.032,0.048,0.056,0.075,0.029,0.072,0.034,0.064,0.043,0.053,0.037,0.039,0.079,0.022,0.042,0.023,0.02,0.019,0.018,0.016,0.015,0.014,0.013,0.012,0.011,0.01,0.017,0.015,0.016,0.014,0.013,0.018,0.019,0.012,0.011,0.017,0.02,0.022,0.024,0.025,0.023,0.026,0.027,0.028,0.029,0.03,0.032,0.033,0.034,0.035,0.036,0.037,0.038,0.039,0.04,0.041,0.042,0.043,0.044,0.045,0.046,0.047,0.048,0.049,0.05,0.052,0.053,0.054,0.055,0.056,0.057,0.058,0.06,0.061,0.062,0.063,0.064,0.065,0.066,0.067,0.068,0.069,0.07,0.071,0.073,0.074,0.075,0.076,0.077,0.078,0.079
```
阅读全文