随机生成100个1到1000随机数,10个元素为一行
时间: 2024-05-08 10:21:52 浏览: 50
下面是Python代码实现:
```python
import random
# 生成100个1到1000之间的随机数
nums = [random.randint(1, 1000) for _ in range(100)]
# 每10个元素为一行输出
for i in range(0, 100, 10):
print(nums[i:i+10])
```
输出结果如下:
```
[264, 837, 727, 513, 46, 559, 269, 378, 276, 455]
[321, 764, 793, 172, 977, 624, 785, 323, 218, 868]
[199, 880, 476, 206, 393, 569, 997, 463, 450, 540]
[612, 977, 183, 883, 889, 838, 66, 827, 383, 372]
[560, 524, 649, 666, 793, 717, 191, 649, 302, 946]
[356, 177, 963, 977, 592, 223, 778, 621, 947, 53]
[366, 70, 402, 934, 614, 919, 873, 545, 973, 297]
[507, 897, 883, 181, 417, 147, 253, 745, 779, 338]
[60, 873, 779, 125, 798, 984, 844, 890, 658, 320]
[890, 221, 872, 614, 453, 621, 678, 798, 475, 267]
```
阅读全文