Django Web Development Guide

Source: Internet
Author: User
Tags access properties

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.