使用python生成大型矩阵用于测试程序
from numpy import random
from os import path
a=int(input())
b=int(input())
filepath="文件路径"
f=open(filepath,'w+')
f.write(str(a)+' '+str(b)+'\n')
arr=random.randint(0,100,size=(a,b))
for x in arr:
f.write((' ').join(str(y) for y in x)+'\n')
f.close()
比如我们在控制台/终端输入:
10
10
输出的文件:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)