Python Learning Day2 (ii)

Source: Internet
Author: User

1. Class-to-object relationships

For Python, everything is an object, objects are created based on the class

Type is the class that gets the

Dir is to get the members inside this class

2.int Internal Function Introduction

Bit_length: Returns the minimum number of digits that the current number occupies;

Conjugate: Returns the conjugate complex number of a complex number

__ABS__: Return absolute value (or ABS (-11))

__ADD__: Add (+)

__AND__: and operations

__CMP__: Compare two-digit size (canceled in 3.x)

__BOOL__: Converting to a Boolean value

__divmod__: Divide, get quotient and remainder composition Ganso

__eq__: equals (= =)

__FLOAT__: Create new floating-point data based on the original data

__FLOORDIV__: Floor removal (//)

__GE__: greater than or equal to

__GT__: Greater Than

__init__: Construction method

__POW__: Power operation

Plus R is the right-to-left operation.

Float Internal Function Introduction

As_integer_ratio (self): Gets the simplest ratio of the value change

Fromhex (Self, string): Converts a hexadecimal string to a floating-point type

Hex (self): Returns the 16 binary representation of the current value

Introduction to STR internal functions

Capitalize (self): Capitalize first letter

Center (self, Width, fillchar=none): Content centered, Width: total length; Fillchar: padding content in white space, default None

Count (self, sub, Start=none, End=none): Number of subsequence

Decode (self, Encoding=none, Errors=none): Decoding
Encode (self, Encoding=none, Errors=none): encoding, for Unicode
EndsWith (self, suffix, start=none, end=none): Whether to end with XXX
Expandtabs (self, tabsize=none): Converts tab to space, default one tab to 8 spaces
Find (self, sub, Start=none, End=none): Find the sub-sequence position, if not found, return –1
Format (*args, **kwargs): string formatting, dynamic arguments, speaking of functional programming
Index (self, sub, Start=none, End=none): Sub-sequence position, if not found, error
Isalnum (self): whether it is a letter or a number
Isalpha (self): whether it is a letter
IsDigit (self): Whether it is a number
Islower (self): lowercase
Join (self, iterable): Connect
Ljust (self, Width, fillchar=none): Content left aligned, right padding
Lower (self): variable lowercase
Lstrip (self, chars=none): Remove left margin
Partition (self, SEP): Split, front, middle, last three parts
Replace (self, old, new, Count=none): replace
Split (self, Sep=none, Maxsplit=none): Split, maxsplit up to several times
Splitlines (self, Keepends=false): Split by line break
StartsWith (self, prefix, Start=none, End=none): whether to start
Strip (self, Chars=none): Remove both ends of the gap
Swapcase (self): uppercase to lowercase, lowercase to uppercase
Translate (self, table, Deletechars=none): conversion, you need to make a corresponding table, the last one represents the deletion of the character set
Zfill (self, width): The method returns a string of the specified length, the original string is right-aligned, and the front padding is 0.

List Internal function introduction

Append (self, p_object): Adds a new element to the tail of the list. Only one parameter is accepted.

Count (self, value): Counts the number of occurrences of an element in a list

Extend (self, iterable): Accepts only one list as an argument and adds each element of the parameter to the original list.

 
  
Index (self, value, Start=none, Stop=none): Used to find the index position of the first occurrence of a value from the list, and throws an exception if no object is found
 
  
Insert (self, Index, p_object): Inserts an element into the list, but has two parameters (such as insert (1, "G")), the first parameter is the index point, which is the position of the insertion, and the second parameter is the inserted element.
 
  
Pop (self, index=none): Removes an element from the list (the last element by default) and returns the value of the element
 
  
Remove (self, value): Removes the first occurrence of a value in the list.
 
  
Reverse (self): used to reverse the elements in the list
 
  
Sort (self, cmp=none, Key=none, Reverse=false): Sorts the original list and, if specified, uses the comparison function specified by the comparison function
  
 

Introduction to the internal functions of tuple

Count (self, value): Counts the number of occurrences of an element in a tuple

Index (self, value, Start=none, Stop=none): Used to find the index position of the first occurrence of a value from a tuple, and throws an exception if no object is found
  
 

Dict Internal Function Introduction

Clear (self): clear content

Copy (self): shallow copy
 
  
Get (self, k, d=none): Gets the value according to key, D is the default value
 
  
Has_key (self, k): Is there a key
 
  
Items (self): List form for all items
 
  
Iteritems (self): item can be iterated
 
  
Iterkeys (self): Key can iterate
 
  
Itervalues (self): value can be iterated
 
  
Keys (self): List of all keys
 
  
Pop (self, k, d=none): Deletes the value corresponding to the given key, returns the value and removes it from the dictionary
 
  
Popitem (self): randomly returns and deletes a pair of keys and values (items) in the dictionary
 
  
SetDefault (self, k, d=none): If key does not exist, it is created, if present, returns the existing value and does not modify
 
  
Update (self, E=none, **f): Updated
 
  
VALUES (self): all values
 
  
Viewitems (self): All items, just save the content to the View object
  
 

Python Learning Day2 (ii)

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.