Monday, 23 September 2013

working with tuple and file

for i in range(0,100,5):
    print i
# 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.text","r")
y=x.read()
x.close()
print y
#create a file
sunday=open("sunday.txt","w")
sunday.write("I enjoy the sermon of my bishop.\nI went at my frd house.\nlater in the evening i was enjoy myself with mara and clara show.")
sunday.close()
#reading a file
truth=open("sunday.txt","r")
trust=truth.read()
truth.close()
print trust

#appending a file
weekend=open("sunday.txt","a")
weekend.write("\nat twelve in the night,I went to bed.")
weekend.close()

#reading a file
capitol=open("sunday.txt","r")
mountain=capitol.read()
capitol.close()
print (mountain)

No comments:

Post a Comment