strip part of string

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun May 10 17:36:17 CEST 2009


On Sun, 10 May 2009 17:18:51 +0200, Francesco Pietra wrote:

> Hi:
> I would like to delete everything from column 54 on for each line
> beginning with "ATOM". In the example in the attachment (sorry for the
> attachment; I found no way with Google mail to have plain text mail) the
> new line would become:
> 
> ATOM     49  NH1 ARG    84      84.628  41.570  44.395

if line.startswith("ATOM"):
    line = line[0:54].rstrip()

should do what you want.



-- 
Steven



More information about the Python-list mailing list