Re: removing characters before writing to file



eight02645999@xxxxxxxxx wrote:
hi
i have some output that returns a lines of tuples eg

('sometext1', 1421248118, 1, 'P ')
('sometext2', 1421248338, 2, 'S ')
and so on
....


If the braces are always at the begining and at the end of the string,
you could also use:

>>> "('sometext1', 1421248118, 1, 'P ')"[1:-1]
"'sometext1', 1421248118, 1, 'P '"

cheers
Stefan

Attachment: pgp8ltr14EODb.pgp
Description: PGP signature



Relevant Pages

  • Re: Luthier question: Intonating via thinning braces
    ... Is it possible, in your experience, to alter the intonation of one ... string by thinning the braces, whether one brace or more than one. ... Do you recall if your tweaked guitar had a change in intonation? ...
    (rec.music.classical.guitar)
  • Re: empty list
    ... Dan Smart wrote: ... string, and that strings can be converted to lists, and as previously ... stated I'd be very happy if braces actually constructed lists. ...
    (comp.lang.tcl)
  • Re: Curly braces and the logic of PERL
    ... even though an equal number of left & right braces ... much Perl Golf;) The objective of Perl Golf is to write a program to ... # $string is a global containing the string to look for; ... # $REPORT is a global file handle to the output file; ...
    (perl.beginners)
  • Re: Parsing Strings in Enclosed in Curly Braces
    ... x = "{ABC EFG IJK LMN OPQ}" ... Can you have braces legitmately lying around in the string, ... Can you have nested braces, and what are you supposed to do with them: ... Parsing is not an entirely trivial subject, ...
    (comp.lang.python)
  • Re: Dynamic column specification in table update
    ... you need braces to EXEC a string. ... Tibor Karaszi, SQL Server MVP ...
    (microsoft.public.sqlserver.programming)