Step 1:Read each line (each line is of type str)
Step 2:Tabularize each line
Step 3:Eject the /n characters on each line
Step 4:Append, /n three characters
The code is implemented as follows:
#import os From_file=open('D:\\python\\A\\') f=open('','w') count=0 huancun=[] for each_line in From_file: #print(type(each_line)) each_line is a character type Delstr=list(each_line) () # Popping up n () #Eject\ (',\n') huancun="".join(Delstr) print(huancun) (huancun) count+=1 huancun=[] () From_file.close() print('There are a total of: %d lines in the file'%count)
This Python implementation of adding a comma to each line in a file is all that I have shared with you above, and I hope it will give you a reference, and I hope you will support me more.