python

Kevin Fries kevin at fries-biro.com
Sat Oct 11 15:22:39 MST 2014


%s will be the placeholder for a string and %d for a number.  If you used
say 15 as the value, and the template is %s you will get 15.to_s and is the
value was "15" and the template was %d, the value will be "15".to_i.  In
other words it will try to do the appropriate conversion.  So given your
example it worked.  But let's say your template was %d, if you pass as a
value 15 or "15" that would work, but "fifteen" will throw an error.  %s
will work, in all cases, but may not be what you want.

HTH
Kevin
On Oct 11, 2014 1:35 PM, "Michael Havens" <bmike1 at gmail.com> wrote:

> Well, I've decided to try to learn python. Right now I'm on 'format
> string'.So there are different ones, right? Well, I'm working with %d and
> %s right now and if I change the %d to a %s I get the same result when I
> run the program. My question  is %x just a place holder or do they have
> special meanings?
> :-)~MIKE~(-:
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20141011/a1d6d956/attachment.html>


More information about the PLUG-discuss mailing list