Python core programming 4-sequence: String, list, And tuples
1. Sequence member relationship operator (in, not in)
2. Sequence type operators
Functions of sequence Operators
Seq [ind]Obtain the element whose subscript is ind.
Seq [ind1: ind2]Obtains the set of subscripts from ind1 to ind2.
Seq * exprRepeated expr times
Seq1 + seq2Connection sequence seq1 and seq2
Obj in seqDetermine whether the obj element is included in seq
Obj not in seqDetermine whether the obj element is not included in seq
3. Join operator (+): concatenates a sequence with another sequence of the same type.
4. Repeated operators (*)
5. type conversion
Function Description
List (iter)Convert an iteratable object to a list
Str (obj)Convert an obj object to a string (String Representation of the object)
Unicode (obj)Convert an object to a Unicode string (using the default encoding)
Basestring ()Abstract Factory functions only provide the parent class for str and unicode functions, so they cannot be instantiated or called.
Tuple (iter)Converts an iteratable object into a tuples.
6. String formatting symbols
Format character conversion method
% C is converted to a character (ASCII value, or a string of one length)
% Ra converts strings with the repr () function first.
% S String Conversion using the str () function
% D/% I to a signed decimal number
% Ub to unsigned decimal number
% Ob to unsigned octal number
% Xb/% Xb (Unsigned) to Unsigned hexadecimal number (x/X indicates the size of the converted hexadecimal character
Lowercase)
% E/% E into scientific notation (e/E control output e/E)
% F/% F is converted to a floating point number (the fractional part is naturally truncated)
% G/% G % e and % f/% E and % F
% Output %
7. built-in functions cmp (), len (), max (), min (), zip (), enumerate ()
>>> S, t = 'foa', 'obr'
>>> Zip (s, t)
[('F', 'O'), ('O', 'B'), ('A', 'R')]
8. Python does not have the end character nul of the c style. How many characters do you enter? What is the return value of the len () function.
9. Three quotation marks
It can contain line breaks, tabs, and other special characters.
10. The function can return multiple objects.