python-selenium-Tynam study notes 1-python basis

coding

The default encoding format for the script ANSCII , so we need to manually change the format to utf-8 the following format

coding=utf-8或--coding=utf-8--

type of data

There are six types of data:

  • Digital: Contains integer (int), floating point (float), Boolean (bool), a complex type (complex)
  • String: represents a series of characters, used when needed '', "" comprising
  • List: Use [], a specific sequence elements, using the "comma" split between elements and element values ​​may be modified
  • Tuples: the same list, but can not be modified element value, and the length is fixed, using () represents
  • Dictionary: key-value pair with a key represented, can store any type of data, using {} indicates
  • Set: a set of non-overlapping random sequence of elements (a list of contrast), using {} indicates

Operators

  • % Denotes a remainder, // represents taking divisible, return business section
  • and is == What is the difference? , IS is the comparison target position is the same, but
    == is the same whether the comparison object value
  • and, and, or, or, not non

Statement

  • if condition is determined [The statements] the else [The statements]
  • Loop include, for, the while, the Continue and for all break out of the loop, the former indicating the end of the current cycle, which means exit loop

List CRUD

append- end of a list element is added, extend- list to add more elements, insert- additive element specified position, remove (name) - removal of a specific element, del list [index] - remove the element index index

Anonymous function

Using lambda create anonymous functions.
Syntax: lambda parameter 1, parameter 2, ... Parameters n: Expressions
Features:

  • ambda can contain only one statement;
  • Alternatively parameters, can be 0;
  • You need to write return, return directly behind the expression;
  • When ambda and functions def defined as the need to call will be executed;
  • The expression of the generating function is generally relatively simple

abnormal

try:
    执行代码块
except (错误类型):
    处理异常代码块
except Exception:
    处理异常代码块
finally:
    最后执行

Guess you like

Origin www.cnblogs.com/ptest/p/11652099.html