Printing "%" 
Author Message
 Printing "%"

How do you print a percenrage (%)sign in Python?
I tried :
  return "select * from fax where id LIKE '%s\%'" %ident

I get the following error
 File "/home/mixo/faxserv/cgi-bin/OutputStr.py", line 136, in GetFaxPages
    return "select * from fax where id LIKE '%s\%'" %ident
TypeError: not enough arguments for format string

Please help!



Mon, 15 Sep 2003 23:58:46 GMT  
 Printing "%"

Quote:

> How do you print a percenrage (%)sign in Python?
> I tried :
>   return "select * from fax where id LIKE '%s\%'" %ident

Use %% instead:

Python 2.0 (#5, Nov 10 2000, 21:47:15)
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.

Quote:
>>> "We're at %f%%" % 200

"We're at 200.000000%"

--

 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ People are taught to be racists.
\__/ Jose Abad
    Esperanto reference / http://mirror/alcyone/max/lang/esperanto/
 An Esperanto reference for English speakers.



Tue, 16 Sep 2003 00:03:20 GMT  
 Printing "%"

Quote:

> How do you print a percenrage (%)sign in Python?
> I tried :
>   return "select * from fax where id LIKE '%s\%'" %ident

As the manual says, it works just like the C printf conversion does.
Try:
    return "select * from fax where id LIKE '%s%%'" % ident

--
Bob Kline

http://www.rksystems.com



Tue, 16 Sep 2003 00:27:16 GMT  
 Printing "%"
Sez Mix:

Quote:
> How do you print a percenrage (%)sign in Python?
> I tried :
>   return "select * from fax where id LIKE '%s\%'" %ident

Use double %-sign:
  return "select * from fax where id LIKE '%s%%'" % ident

Peace,
  Kalle
--

Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8)
PGP fingerprint: 0C56 B171 8159 327F 1824 F5DE 74D7 80D7 BF3B B1DD
 [ Not signed due to lossage.  Blame Microsoft Outlook Express. ]



Tue, 16 Sep 2003 00:24:18 GMT  
 Printing "%"

Quote:

> How do you print a percenrage (%)sign in Python?
> I tried :
>   return "select * from fax where id LIKE '%s\%'" %ident

Do the following:

    >>> "%i%%" % 85
    '85%'

Or, in your case,

    return "select * from fax where id LIKE '%s%%'" %ident

-Steve

--
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo



Tue, 16 Sep 2003 00:31:28 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. string.join(["Tk 4.2p2", "Python 1.4", "Win32", "free"], "for")

2. BEGIN{want[]={"s1o", "s2o", "s2q", "s3q"}

3. Hi, this code: text0 = "One $BLAH Three" text1 = "One @BLAH Three" text0.sub!("$BLAH", "Two") text1.sub!("@BLAH", "Two") print text0,"\n" print text1,"\n" produces thiHi, this code: text0 = "One $BLAH Three" text1 = "One @BLAH Three" text0.sub!("$BLAH", "T

4. Parsing ""D""?

5. "Fifth", "Forth", zai nar?

6. Ruby "finalize", "__del__"

7. beginners "let"/"random" question

8. ANNOUNCE: new "plus"- and "dash"-patches available for Tcl7.5a2/Tk4.1a2

9. Looking for "stdin", "stdout"

10. Printing "bad" font

11. Printing "reports" with RealBasic

12. Printing "DAS Tagged" Records problem

 

 
Powered by phpBB® Forum Software