remove last line of file python code example
Example: remove last line of text file python
fd=open("file.txt","r")
d=fd.read()
fd.close()
m=d.split("\n")
s="\n".join(m[:-1])
fd=open("file.txt","w+")
for i in range(len(s)):
fd.write(s[i])
fd.close()