Remove illegal characters contained in list Val_list, Illegal_char is a list of illegal characters
Def clear ():
Illegal_char = [' ', ' # ', '% ', ' _ ', ' @ ']
Tmp_list = []
Val_list = [' Aaaaaaaa a A a 1%dddd%[email protected]@@@@@111 #111 ', ' bbbbbbbbb_ggg_g_g-bbls## 222222222222###-']
For I in Illegal_char:
For J in Val_list:
val = re.sub (i, ", j)
Tmp_list.append (Val) # Remove the first type of illegal word specifier (such as ' # ') to add all the data to a temporary list tmp_list
Val_list = [] # empties the list of previously stored data and then puts the cleansed data back into the data list val_list
Val_list = Tmp_list
Tmp_list = [] # to avoid cleaning up once to add data to the temporary list causes the number of cleanup times to double the data, all to erase the tmp_list
Return val_list
Print Clear ()
Python clears useless characters from a string