If you want to keep the spaces after each line in the file, you can open the file in binary mode, so that the space characters at the end of the line will not be automatically deleted when reading the file. For example, when you open a file, specify the mode as "rb", that is, you can read the file in binary mode:
Use open('test.txt',' rb') as f:
contents = f.read()
Note that when you open a file in binary mode, what you read will be regarded as a byte string instead of a string, and you need to convert it accordingly. If you want to write a file in text mode, you need to explicitly add blank characters at the end of the line when writing.
If it helps you, please accept it. Thank you~
Fitter's practice report 1
Metalworking practice is a very practical technical basic course. We practiced in the Mechanical Practice Center f