目前得到这个输出如何在每个循环后添加新行?
[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
你能更具体一点吗?你想在印刷时以某种方式看起来结果?我看起来像你想要一个2D数组。 – reticentroot
@reticentroot尝试创建一个用于测试(3485,6758,8094)的随机数字文件,但在一个新行上创建了每组4个数字。 – scorpionz