Problems With stringformating... URGEND

Ivan Van Laningham ivanlan at callware.com
Thu Dec 30 09:31:28 EST 1999


Hi All, Kurzmann--

Kurzmann Martin wrote:
> 
> Hi !
> 
> i'm a kind of newbie in python an at now i have following problem:
> 
> i will format the follosing text and insert some Variables
> (excerpt of my code)
> 
> print "\n BEFORE MSG \n"
> 
> msg="""Sehr geehrte/r %s !
> 
> Treffer! Diesen Moment sind neue Inserate auf unserem Online-Server im
> Bereich %s eingelangt, die unser Suchagent für Sie aufgespürt hat,
> passend zu Ihrer gespeicherten Suchabfrage.
> 
> Genau diese Inserate können Sie unter folgender Adresse abrufen:
> http://xxx.xx.xxx.xx/%s/anzclu_%s.taf?_what=search&suchtyp=6&qid=%d
> 
> Wir freuen uns auf Ihren Besuch und wünschen Ihnen viel Erfolg beim
> Suchen und Inserieren!
> 
> Mit freundlichen Grüßen,
> das Kleine Zeitung Online Team
> 
> PS: Für Anregungen und Kritik in Bezug auf unsere Online-Dienste sind
> wir sehr dankbar.
> 
> Mail an den Webmaster (webmaster at kleinezeitung.at) genügt!
> 
> Kleine Zeitung Online: http://www.kleinezeitung.at
> 

Change this line from:

> """ %emailrec, markt_alt, markt, markt, id

to:

> """ %(emailrec, markt_alt, markt, markt, id)

The % operator with strings *requires* a tuple; a single item not in a
tuple is treated as a 1-element tuple, and this is probably what's
confusing you.  Make it a habit to always tuplize items feeding %.

> 
> print "\n AFTER MSG \n"
> print "\n" + msg + "\n"
> 
> ANY IDEA WHATS wrong??
> 
> thanks in advance and a happy Y2K !!
> 

<care-and-feeding-of-%-is-simpler-than-for-a-snake>-ly y'rs,
Ivan
----------------------------------------------
Ivan Van Laningham
Callware Technologies, Inc.
ivanlan at callware.com
ivanlan at home.com
http://www.pauahtun.org
See also: 
http://www.foretec.com/python/workshops/1998-11/proceedings.html
Army Signal Corps:  Cu Chi, Class of '70
Author:  Teach Yourself Python in 24 Hours
----------------------------------------------




More information about the Python-list mailing list