append a line to a text file python
# Open a file with access mode 'a'
file_object = open('sample.txt', 'a')
# Append 'hello' at the end of file
file_object.write('hello')
# Close the file
file_object.close()
append a line to a text file python
# Open a file with access mode 'a'
file_object = open('sample.txt', 'a')
# Append 'hello' at the end of file
file_object.write('hello')
# Close the file
file_object.close()
how to add line inside a file
how to add lines inside a file
sed -i -e "48r../../../../folder1/lines_to_add.txt" a.txt
a.txt - file you want to change
48r is line number of a.txt
some lines are inside lines_to_add.txt file
../../../../scripts3_2d/lines_to_add.txt
-i update a.txt, try without -i before runthe code,
be carefull with newlines,
"keep a newline at the end of lines_to_add.txt"
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us