[Python] Basic commands, functions and Math
# (octothorpe or pound character)
myName = "Rovingleaves"
myAge = 40
print "my name is %s. I am %d years old" % (myName, myAge)
Everything after the # is ignored by python.print "text"
string in "" will be printed out.Integer and Float
1/4 = 0 (int)
1.00 / 4 = (float)% (modulus)
75 % 4 = 3 (75 = 18 * 4 + 3)
2 % 4 = 2Variable
myName = "Rovingleaves"
myAge = 40
print "my name is %s. I am %d years old" % (myName, myAge)
- s: String (converts any python object using str()).
- d: Signed integer decimal.
- f: Floating point decimal format.
- x: Unsigned hexadecimal (lowercase).
- X: Unsigned hexadecimal (Uppercase).

留言
張貼留言