I am in the process of trying to teach myself python so I am very new to this. My code is pretty simple. I just have a numpy array that I have randomly generated with integers. My code looks like this
arr = np.random.randint(100, size=(5,5))
print(arr)
When it prints it prints with brackets around it like this
[[98 87 45 5 67]
[33 39 1 40 96]
[97 55 85 2 65]
[18 28 32 55 21]
[96 46 14 87 28]]
How do I remove all of the brackets so it is only the numbers with the spaces between?
re.subto replace the brackets after converting the bumpy array to a stringimport reprint(re.sub('[\[\]]', '', np.array_str(arr)))numpytask. Still it might be useful to look at the code fornp.savetxt, and try to imitate that.