I am making a program with Python with subprocess and take with stdout specific part of the messages(specific word) and make it string. Then I am saving this word to a .txt. But the problem is that this word is surrounded with this chars ['word'] . When it is string I am trying to remove them, but the result is the same. If someone know why I have this chars or other way to remove them I will be greatfull.
def remove_char(string):
string=list(string)
string.remove('\'')
string.remove('[')
string.remove(']')
#string.remove('F')
return''.join(string)
#code
newID=str(ID)
remove_char(newID)
file=open('C:\\Users\\admin\\Desktop\\...\\...\\proba.txt', 'w')
file.write(newID)
file.close