Monday 23 September 2013

working with file

#creating range

for item in range(0,100,5):
    print item
   
#working with file in python

crip=open('flash.txt','w')
crip.write('sing the melody')
crip.close()
#print crip

#reading a file
x=open('flash.txt','r')
y=x.read()
x.close()
print (y)

#creating my own file
good_day=open('rise.txt','w')
good_day.write('I enjoy my sunday very well with my sister on her birthday')
good_day.close()
#print good_day

happy=open('rise.txt','r')
well=happy.read()
happy.close()
print (well)

#appending a file
good_day=open('rise.txt','a')
good_day.write('The both of us went for service at my church')
good_day.close()
print good_day

happy=open('rise.txt','r')
well=happy.read()
happy.close()
print(well)




No comments:

Post a Comment