Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Write a Python program to append text to a file and display the text.

def Appendtext(fname):
	with open(fname,'a+') as f:
		f.write('appending line 1, ')
		f.write('appending line 2. ')
	f.close()
# y=open('file1.txt')
# print(y.read())
Appendtext('file1.txt')

x= open('file1.txt')
print(x.read())
Comment

PREVIOUS NEXT
Code Example
Python :: datetime one month ago python 
Python :: how to sum the revenue from every day in a dataframe python 
Python :: scikit learn r2 score 
Python :: pandas multiple string contains 
Python :: jupyter read in csv 
Python :: mp4 to mp3 in python 
Python :: select python version ubuntu 
Python :: python get last modification time of file 
Python :: size table python 
Python :: python day from date 
Python :: how to get a list of all values in a column df 
Python :: Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module from pip import main 
Python :: check key pressed pygame 
Python :: convert integer to datetime in python 
Python :: Extract categorical data features 
Python :: cv2 load image 
Python :: how to subtract 2 lists in python 
Python :: sort list by attribute python 
Python :: figure title python 
Python :: jupyter notebook how to set max display row columns matrix numpy 
Python :: skimage image read 
Python :: how to use python to print multiplication table 
Python :: write set to txt python 
Python :: require http method django view 
Python :: AttributeError: This QueryDict instance is immutable django 
Python :: how to read zip csv file in python 
Python :: py random list integers 
Python :: wxpython change window size 
Python :: day difference between two dates in python 
Python :: remainder identifying python 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =