Percent sign in format string?

Mark McEahern marklists at mceahern.com
Thu Jul 18 20:45:48 EDT 2002


print "%d%%" % 98

in other words, % is an escape character that lets you print %.

// m

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Ron Levine
> Sent: Thursday, July 18, 2002 7:33 PM
> To: python-list at python.org
> Subject: Percent sign in format string?
> 
> 
> 
> How can I put a "%" sign in a format string?
> 
> For example, x=98 and  I want to output
>  "x = 98%"
> 
> The statement
>      print "x = %d%"%x 
> produces a ValueError: incomplete format string
> 
> So does the statement
>      print "x = %d\%"%x 
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> -
> 
> 
-






More information about the Python-list mailing list