Usage Scenario: Need to remove spaces, numbers, specific letters, etc. from txt text.
The txt text to be modified is called:
Modified and saved as: train_output.txt
# ecoding=utf-8 ifn = r"" ofn = r"train_output.txt" infile = open(ifn,'rb') outfile = open(ofn,'wb') for eachline in (): # Remove spaces, \t, numbers inside the text line (others to be removed can also be put into '\t1234567890') lines = filter(lambda ch: ch not in ' \t1234567890', eachline) (lines) # Write to train_output.txt (here it's all in one place, without any branching)
The above method of this python to remove spaces, numbers, specific letters, etc. from txt text is all that I have shared with you, and I hope it will give you a reference, and I hope you will support me more.