Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python insert on a specific line from file

f = open("path_to_file", "r")
contents = f.readlines()
f.close()

contents.insert(index, value)

f = open("path_to_file", "w")
contents = "".join(contents)
f.write(contents)
f.close()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #insert #specific #line #file
ADD COMMENT
Topic
Name
3+9 =