Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103535 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2016-02-26 12:31 +0100 |
| Last post | 2016-02-26 12:31 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: How to remove the line numbers from the file in python Peter Otten <__peter__@web.de> - 2016-02-26 12:31 +0100
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2016-02-26 12:31 +0100 |
| Subject | Re: How to remove the line numbers from the file in python |
| Message-ID | <mailman.146.1456486281.20994.python-list@python.org> |
Ganesh Pal wrote:
> what would be the easiest way to remove the lines in the leading
> numbers 1.e 1 ,2,.... 19 from this file using python ?
>
>
> 1 import os
> 2 Suite = "Test Mail"
> 3
> 4 def sendMail(x):
> 5 text = x
> 6 sendmail_location = "/home/prasad/onefs/share/sendmail" #
> sendmail location
> 7 p = os.popen("%s -t" % sendmail_location, "w")
> 8 p.write("From: %s\n" % "ganesh.pal@gmail.com")
> 9 p.write("To: %s\n" % "ganesh.pal@gmail.com")
> 10 #p.write("To: %s\n" % "umamaheshwar.b@gmail.com")
> 11 p.write("Subject: Suite : %s \n" % (Suite))
> 12 p.write("\n") # blank line separating headers from body
> 13 p.write("%s" %text)
> 14 status = p.close()
> 15
> 16 if status != 0:
> 17 print "Sendmail exit status", status
> 18
> 19 sendMail("Test Mail")
sys.stdout.writelines(
line.lstrip().lstrip("0123456789")[1:] or "\n"
for line in sys.stdin)
Replace stdin/out with files as needed.
Back to top | Article view | comp.lang.python
csiph-web