delete a line from a text file

Asked by MJ on 2017-08-13

this is my current code that reads a line from a text file then types the in the screen. how do i delete the line from the text file? how do i append that line into another text file?

idsList = [] # empty list/array
dir = "c:/sikuli/" # the folder, where your ids.txt is
idsFile = os.path.join(dir, "type.txt") # makes a Windows filename
f = open(idsFile) # opens ids file
for line in f.readlines(): # reads line by line
    id = line.strip() # get rid of newline
# print id
    idsList.append(id) # add id to list/array
f.close() # close file
type(id)

Thanks very much

Question information

Language:
English Edit question
Status:
Expired
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2017-08-13
Last reply:
2017-08-29
MJ (mjpmgr) said : #1

just read line 1 from text file1, delete that line, and append that line to file2

Launchpad Janitor (janitor) said : #2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.