Python Basics (9): Supplemental

Source: Internet
Author: User

1. Class ():

Automatically call internal method __init__ ()

int (), str (), list (), bool (), tuple (), Dict (), object-oriented class.

2. Int:

  A. Method of Creation (two):

1). A = 123

2). A = in (123)

__init__ (self, x, base=10): x: Number. Base: The default is 10 binary.

B. Additions:

python internal optimization: A duplicate default memory address within the range ( -5< contains > ~257< does not include >)

    View memory address: ID (variable name)

    view string, array length:len (string, array)

C. Length limitation:

int type:

32-bit system: integer with 32 bits, value range: -2**31~2**31-1 ( -2147483648~2147483647)

64-bit system: integer with 64 bits, value range: -2**63~2**63-1 ( -9223372036854775808~9223372036854775807)

Automatically converted to a long type after it is exceeded.

Long type:

No length limit, determined by memory size.

bytes

3. STR:

A. String creation (two ways):

S1 = "Alex"

S1 = str ("Alex")

__init___ (Self, value= ", Encoding=none, errors= ' strict '): Value: The content parameter of the string. Encoding: Encoding defaults to none. Errors: The default is strict mode (strict), which is not changed by default.

No arguments: Creates an empty string.

1 Parameters: Create a normal string

2 parameters: Int (bytes, encoded)

B. Specific methods:

Strip (): Go to both ends of the space.

Lstrip (): left blank.

Rstrip (): Go to the right space.

StartsWith (): Start with XXX.

EndsWith (): End With XXX.

Find (): Finds a subsequence (can be one character or more than one character).

Replace (): Replaces a subsequence in a string with the specified value.

Upper (): variable capitalization.

Lower (): lowercase.

Isalnum (): Whether it is a letter or a number.

Isalpha (): Whether it is a letter or not.

IsDigit (): Determines whether it is a number.

Islower (): Determines whether it is lowercase.

Isspace (): Determines whether it is a space.

Istitle (): Determines whether it is a title.

Isupper (): Determines whether it is uppercase.

C. Public methods:

Index: [0],[1] ... Only one element can be taken

Slice: [0:1],[0:2] ... Multiple elements are preferable

Coding:

Len ():

For

Python Basics (9): Supplemental

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.