I wrote a code which is meant to replace a tag from a string with a number extracted from an array.
This is part of a bigger project but I only isolated the problematic part
# import numpy as np
time_vect = np.arange(0, 10, 1)
string = "T= <T>"
for i in range(0, len(time_vect),1):
string = string.replace("<T>", str(time_vect[i]))
print(string)
However the replace function seems to totally ignore the value. When I run the code I get this output :
T= 0
T= 0
T= 0
T= 0
T= 0
T= 0
T= 0
T= 0
T= 0
T= 0
When I assign the value manually, I get the expected result
>> print(string.replace("<T>", str(time_vect[3])))
T= 3
I tried to convert the numpy.int32 type into native int type but it did not solve the problem
string = string.replace("<T>", str(time_vect[i].item()))
I could not find any leads on the net so I would be thankful if I could get some support :)