Quick Reference
Data Type Conversion
type(object)
strVar = str(100)
floatNum = float(100)
num = int(math.ceil(3.14))
num = int(math.floor(3.14))
strVar = str(3.14)
num = int("100")
floatNum = float("3.14")
System Interaction
C:\> "C:\path\python\bin\python.exe" script.py paras
$ /path/python script.py paras
import sys
len(sys.argv)
sys.argv[index]
import sys, getopt
opts, args = getopt.getopt(\
sys.argv[1:], "fi:o:", ["help", "paras="])
String
strVar = "abcde"
strVar = 'abcde'
multiLineStr = """
This is first line.
This is second line.
"""
strVar = u"This is the unicode string."
strVar[index]
strVar[startIndex : endIndex+1]
strVar[startIndex : endIndex+1 : increment ]
conStr = "This is the " + "replaced" + " " + "string."
conStr = ("There are {} {} words.").format(2,"replaced")
conStr = ("The string of number is %5.2f to fixed" % 3.14)
len(str)
str.count("findStr", beg = 0, end = len(str))
str.decode(encoding = "UTF-8")
str.encode(encoding = "UTF-8")
str.find("findStr", beg = 0, end = len(str))
str.replace(old, new)
str.split(str = "splitStr")
str.upper()
str.lower()
str.isalnum()
str.isalpha()
str.isdigit()
str.islower()
str.isnumeric()
str.isupper()