Python : writing to a file

Ganesh Pal ganesh1pal at gmail.com
Sat Jan 10 16:14:09 CET 2015


Please provide you input on the below questions:


(a) I was expecting  the string i.e day of week , example Saturday to be
written in the file. what Iam I missing in the below program  ?

Program:

#!/usr/bin/python

import time
f = open ('test_2.txt','w+b')
DAY = time.strftime("%A")
f.write(DAY)
f.close()

Throttling-1# cat test_2.txt

(b) Iam trying to generate a file in the below format ,

cluster1# cat test_2.txt

Saturday 0:05 0:10
Saturday 0:10 0:20
Saturday 0:20 0:30
Saturday 0:40 0:50
Saturday 0:60 0:70

(a) what is the easiest way to generate the above file fprmat ?

(b) how will I take care that the below format is repeated in the .txt file
  ( i.e column and row spacing)

    DAY OF THE WEEK  [SPACE] START TIME [ SPACE] ENDTIME{SPACE]


(c) how do I  add START TIME [ SPACE] ENDTIME{SPACE] columns



Regards,
Ganesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150110/3f941274/attachment.html>


More information about the Python-list mailing list