Python : writing to a file

Ganesh Pal ganesh1pal at gmail.com
Sun Jan 11 11:01:46 CET 2015


On Sun, Jan 11, 2015 at 2:17 PM, Dave Angel <davea at davea.name> wrote:
>
>
> You chopped off the output there.  It probably looked like this:
>
>
> node-1# cat test_2.txt
> Sundaynode-1#
>
>
> Your output is there, right before the prompt.  Since you neglected the
> newline in your code, that's what you'd expect, wouldn't you?
>
> Incidentally, in most systems that prompt would mean you're running as root.
> Bad idea, especially when you're learning to program.
>

I didn't get the output before the prompt ,I actually didn't chop off
the output . below is the complete flow.

# cat get_day.py
#!/usr/bin/python

import time
f = open ('test_a.txt','wb+')
DAY = time.strftime("%A")
f.write(DAY)
f.close()
Throttling-1# python get_day.py


node-1# cat test_a.txt   // This didn't give any result

node-1# less test_a.txt //  I can see the text here
Sunday
test_a.txt (END)



Regards,
Ganesh



More information about the Python-list mailing list