Python core programming Four-sequence: string, list, tuple

Source: Internet
Author: User

1. Sequence member relationship operator (in, not in)


2. Sequence type operators

Sequence operator action
Seq[ind] get the element labeled IND
Seq[ind1:ind2] Gets the set of elements from Ind1 to Ind2
seq * expr sequence repeats expr times
seq1 + seq2 connection sequence seq1 and SEQ2
obj in seq determines if the obj element is contained in a SEQ
obj not in seq determines if the obj element is not included in the SEQ


3. Join operator (+): One sequence is connected to another sequence of the same type.


4. Repeat operator (*)


5. Type conversion

function meaning
List (ITER) converts an iterative object to a table
str (obj) converts the Obj object to a string (the string representation of the object)
Unicode (obj) converts an object to a Unicode string (using the default encoding)
The basestring () abstract Factory function, which simply provides the parent class for STR and Unicode functions, cannot be instantiated or called
A tuple (ITER) converts an iterative object to a tuple object


6. String Formatting symbols

Format Character Conversion mode
%c converted to character (ASCII value, or string of length one)
%ra takes precedence over string conversions with the repr () function
%s takes precedence over string conversion with the STR () function
%d/%i turns into signed decimal number
%ub converted to unsigned decimal number
%ob turns into unsigned octal number
%XB/%XB (Unsigned) turns to unsigned hexadecimal number (x/x represents the size of the converted hexadecimal character
lowercase
%e/%e turns into scientific notation (e/e control output e/e)
%f/%f into floating-point numbers (fractional parts are naturally truncated)
Shorthand for%g/%g%e and%f/%e and%f
% OUTPUT%


7. Built-in function cmp (), Len (), Max (), min (), zip (), enumerate ()

>>> s, t = ' Foa ', ' OBR '
>>> zip (S, t)
[(' F ', ' O '), (' O ', ' B '), (' A ', ' R ')]


8.Python There is no C-style end character nul, you enter how many characters, Len () function return value is how much.


9. Three quotation marks

Triple quotation marks it allows a string to span multiple lines, and the string can contain line breaks, tabs, and other special characters.


10. Function can return multiple objects

Python core programming Four-sequence: string, list, tuple

Related Article

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.