#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0

    Another Newbie ? What's the difference between %u and %s


    x = "There are %d types of people." % 10
    binary = "binary"
    do_not = "don't"
    y = "Those who know %u and those who %u." % (binary, do_not)
    print x
    print y
    print "I said: %r." % x
    print "I also said: '%u'." % y
    hilarious = False
    joke_evaluation = "Isn't that joke so funny?! %r"
    print joke_evaluation % hilarious
    w = "This is the left side of..."
    e = "a string with a right side."
    print w + e

    Why when I use %u it doesn't work, but if I use %s it does work?

    and I'm suppused to be using the # sign to post these post I tried that but the preview it looked like it would be hard to read for others so put it simple text
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    6
    Rep Power
    0
    u - the argument is treated as an integer, and presented as an unsigned decimal number.

    s - the argument is treated as and presented as a string.

    looks like this in the answer even though I don't understand it yet
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    616
    Rep Power
    65
    %u is an obsolete type it is identical to %d for numbers
    You can use %s for strings and numbers.
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo