2015-7-14 20:43:44
P14: ' Raw ' designator tells the interpreter not to convert any special characters in the string ... For example: filename = R ' C:\temp\newfolder\robots.txt '. To maintain consistency, the raw string is usually used regardless of whether a regular expression uses a backslash.
P18:dict.get (' key ' [, ' does not exist this key ']) is more secure than using dict[' key ' directly, because the Get method always returns a value (the default is None). You can also use the setdefault (' key ', ' value ') method, which acts like get, and if the key does not exist, it will automatically create a key-value pair using the default value, so that the subsequent call to the key will not produce an error.
P23: Common python Exceptions:
Assertionerror assert (assertion) statement failed
Arrtibuteerror attempts to access properties that an object does not have, such as foo.x, but Foo has no attribute x
IOError Input/Output exception, basically cannot open file
Importerror cannot introduce modules or packages; it's basically a path problem.
indentationerror syntax error; code not aligned correctly
indexerror Subscript index is out of sequence boundary, for example, when X has only three elements, but tries to access X[5]
Keyerror attempts to access keys that do not exist in the dictionary
Keyboardinterrupt CTRL + C key is pressed
nameerror Using a variable that has not been assigned to an object
SyntaxError Python code is illegal, code cannot mutate
TypeError The Incoming object type does not match the requirements
Unboundlocalerror attempts to access a local variable that is not set, basically because another global variable with the same name causes you to think that you are accessing it
ValueError Pass in a value that is not expected by the caller, even if the value is of the correct type
P24:httplib module no longer exists ...
Django Web Development Guide