Literals

Numbers

     12345                   # Integer (same as C long type)
     0644                    # Integer - Octal
     0xfea844                # Integer - Hexadecimal
     123.45                  # Floating point (64-bit double precision)
     1.2345e+02              # Floating point - Exponential notation
     123456L                 # Arbitrary precision integer
     12 + 34J                # Complex number
     

Strings

     '...'                   # Single quoted string
     "..."                   # Double quoted strings
     '''...''', """..."""    # Triple-quoted strings
     r'...'                  # Raw string 
  • Triple quoted strings capture all text verbatim until matching end quotes.
  • Raw strings preserve backslash characters (\). Not interpreted as escape codes.
  • Adjacant strings are concatenated.
<<< O'Reilly OSCON 2000, Introduction to Python, Slide 29
July 17, 2000, beazley@cs.uchicago.edu
>>>