Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83502 > unrolled thread
| Started by | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| First post | 2015-01-10 20:44 +0530 |
| Last post | 2015-01-11 04:06 +1100 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
Python : writing to a file Ganesh Pal <ganesh1pal@gmail.com> - 2015-01-10 20:44 +0530
Re: Python : writing to a file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-11 04:06 +1100
| From | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| Date | 2015-01-10 20:44 +0530 |
| Subject | Python : writing to a file |
| Message-ID | <mailman.17565.1420902853.18130.python-list@python.org> |
[Multipart message — attachments visible in raw view] — view raw
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
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2015-01-11 04:06 +1100 |
| Message-ID | <54b15c31$0$13001$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #83502 |
Ganesh Pal wrote: > Throttling-1# cat test_2.txt Are you running these scripts as root? That could be a bad idea. If you have a bug in your code, as often happens when coding, who knows what it might do. E.g. if you put in the wrong pathname, you could overwrite important files. You should always do your coding as a regular user, not root. -- Steven
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web