2016-5-15 S3 Study Notes

Source: Internet
Author: User

    • Coding:

Both GBK and UTF-8 are optimized for Unicode encoding, where UTF-8 man uses 3 bytes, 24 bits represent GBK man using 2 bytes, 16 bits, GBK and UTF-8 relationships

1. In Python2, how to convert UTF-8 to GBK requires the manager to decode the UTF-8 into Unicode, in Unicode encoded into GBK

2, Python3, there is no decoding module, can be directly encoded into the UTF-8 gbk,python3 internal conversion.

3, Microsoft's window, the Unicode encoding can be directly converted to their own required encoding.

4. You can view the encoding of the variable through print isinstance (A.unicode), only to see if it is Unicode

Operator:

Arithmetic operations:

+ Two numbers added-two numbers subtracted * Two numbers multiplied/two digits of division% take Division remainder * * Power operation//Take division integer part

Note/in Python2, modules need to be introduced to display the correct

Comparison operation

= = Two objects equal! = Two objects unequal <> two objects unequal > greater than < less than >= greater than or equal to <= less than equals

Assignment operations

= Example C=a+b

+ = Example C+=a equivalent c=c+a

-= Example C-=a equivalent c=c-a

/= Example C/=a equivalent c=c/a

%= Example C%=a equivalent c=c%a

**= Example C**=a equivalent c=c**a

= Example C//=a equivalent c=c//a

Logical operations

And and X are true x and Y are false, return the computed value of y

Or or X is true x or Y is the computed value of Ture return y

Not non-X is true returns false, such as song X is false he returns true

Member operations

In if the value found in the established sequence returns true, otherwise false is returned

Not in if the love-drawn sequence does not find a value that returns true, otherwise false

Basic data types

In Pychram, press and hold CTRL, and then click Use, and you'll get out, in the Python interpreter, enter dir (str) or help (str) for assistance

int (integer type)

32-bit machine -2**32 ~ 2**32 i.e. -2147483648~2147483647 more than long

64-bit machine -2**64 ~ 2**64 i.e. -9223372036854775808~9223372036854775808 more than long

Usage len length, which indicates the number of digits that are least occupied

Boolean value:

True or FALSE. 1 or 0

String

"Hello World"

capitalize (capitalize first letter)

Center (20,****) content centered, length 20, filled with special characters

Count (' value ', start, end) calculation-number of operator elements starting from 0

Deconde decoding (original value, target value decoding format)

EndsWith whether to end with XXX

Expandtabs the tab to a space, and the default tab is converted to 8 spaces

Find (' value ', start position, end position) finds the problem value of the system sequence, returns 1 if not found

1, find the location of the index

2, not found return-1

Index is the same as find, but no find works

Whether the isalnum contains letters and numbers

Isalpha whether the letter

Cannot contain spaces

Whether the isdigit is a number

Islower (whether lowercase)

Join connection

Enter or leave a string, either a special symbol or a letter

Ljust content left-aligned, right-padded

Lower variable lowercase

Lstrip removing left margin

Partitioon split, divided into front, middle, and back three parts

Replace replace (old,new,1) replaces the value inside the string, 1 indicates the substitution of the first number

Strip remove two gaps

Slicing [1:4] 1<k<=4

Lists List

Len length

Slice

Append append value appended to the list

COUNT (element Statistics)

Expend (extension) will add data in bulk

Index (index) Gets the indexes of a value

Insert (insert value) (1, ' value ')

POP is removed from the last value in the original list, or you can specify (index) to remove the specified value

Remove Delete

Reverse reverses the values in the list in flashbacks

del [index] deletes the value of the specified index

Sort sorts

Ganso can not be modified, there are slicing, sorting, statistical functions

Dictionary:

Get the value based on key, if key does not exist, you can set the default value of Get (key value, default value)

Items get all the keys and values

Keys get derived keys

Values gets all the value

Update Bulk Update batch updates another list to a list in

Clear condition All content

Pop

Popitem

2016-5-15 S3 Study Notes

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.