Python Learning Notes

Source: Internet
Author: User

2 important functions of the set:

Relationship testing and de-weight

File code:

Python 2.0x on the default file encoding is ASIC code, ASIC does not support Chinese, so China has GB2312.

UTF-8 is an extension set of Unicode. Unicode is a universal code that contains codes for each country. The default Chinese software encoding for Windows is GBK. GBK backwards compatible with GB2312.

ASIC code: takes up one byte

UTF-8: The English character occupies 1 bytes, the Chinese character occupies 3 bytes, and the UTF8 is variable length.

UniCode: 2 bytes

GBK----------(decode)-------->unicode------(encode)------------->utf-8

Python 3.0 default encoding is Unicode

Function:

Def func_name ():

Key parameter: corresponds to position one by one in the definition when called

Positional parameters: Use the keyword to match the parameters in the definition when calling

Multiple parameters: *args: Display in tuples

**kwargs: Display in dictionary form

Local variables and global variables:

The global variable function is local to declare that it is global

Return: Represents the returned value, or the end of the program

Recursion:

Simply put, recursion is calling yourself.

Conditions for recursion: a. To have a definite end condition, Python allows the maximum number of levels of recursion to be 999 layers.

B. The size of the problem should be less than the previous problem size, and the more efficient the algorithm is, the greater the reduction.

C. Low efficiency

Higher order functions:

Pass in a function as a parameter to another function, and use this function when returning.

Functional Programming:

It is best to learn functional programming in a purely functional programming language. Functional programming has no side-effects. The data passed in is determined, and the result is determined.

File operation:

f = Open

OPEN mode:

R

W (if there would have been this file, directly overwrite, new, so to be backed up),

A (Append)

r+ (3.0, r+ can only write to the end of the file)

w+

A +

RB: Binary format open, in python3.0 is the bytes format. When writing, you need to add encodeing, specify the file format. Cross-platform is best to use binary (linux->windows), video, character stream is also best used in binary.

Wb

Ab

F. Additions and deletions to the search

F.c

The jumping of the position:

F.seek, tell, truncate, flush

Python Learning 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.