【发布时间】:2016-08-28 01:49:45
【问题描述】:
目前正在获取此输出
[1, 1, 3, '\n']
[1, 1, 3, '\n', 7, 7, 7, '\n']
寻找这个输出
[1, 1, 3]
[7, 7, 7]
代码:
import random
my_list=[]
n = 3
m = 1
while m < 10:
for i in range(n): # repeats the following line(s) of code n times
my_list.append(random.randrange(0,9))
my_list.append("\n")
print(my_list)
m = m+1
【问题讨论】:
-
你能再具体一点吗?您希望结果在打印时以某种方式显示?我看起来你想要一个二维数组。
-
@retcentroot 尝试创建一个随机数文件进行测试(3485、6758、8094),但每组 4 个数字在一个新行上。
标签: python python-3.x while-loop