Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

remove last line of text file python

fd=open("file.txt","r")
d=fd.read()
fd.close()
m=d.split("
")
s="
".join(m[:-1])
fd=open("file.txt","w+")
for i in range(len(s)):
    fd.write(s[i])
fd.close()
 
PREVIOUS NEXT
Tagged: #remove #line #text #file #python
ADD COMMENT
Topic
Name
3+3 =