File read/writeOpen path Read/write mode: R w RB WB r+ w+ encoded UTF-8Need closeRecommendedWith openAvoid forgetting that close memory does not releaseIt's still a matter of time. There are two urgent problems in the daytime, not finished.Just a
Monkey patch refers to dynamic substitution at run time, usually at startup.Use Gevent will know, will be at the beginning of the place Gevent.monkey.patch_all (), the standard library in the Thread/socket and so on to replace. So we can use it as
First, Module introduction 1. Modules in PythonA friend with C programming experience knows that if you want to refer to the SQRT function in C, you must use the phrase # include introduce the MATH.H header file, otherwise it cannot be called
= = is a comparison of the values at both endsis to compare memory addresses:The memory address of the data can be obtained with the ID ()In Python, in order to store data in small memory, small data pools are built into the type int and str types,
For example, the read file name is: Poem.txt and the character encoding is GBKContent:Northern scenery, thousands of miles of ice, miles of snow.Look at the Great Wall inside and outside, but Yu vast;Must clear day, see fine feminine attire wrapped,
There is a main thread during the script run, and if a child thread is created in the main thread, one of the following two situations may occur when the main thread ends depending on the Daemon property value of the child thread:
If the
Module Use Example 1ImportSelectorsImportSocketsel=selectors. Defaultselector ()defAccept (sock, mask): conn, addr= Sock.accept ()#should is ready to establish a connection Print('accepted', Conn,' from', addr) conn.setblocking (False)
__del__Item series__getitem____setitem____delitem____hash____eq__Construction method Request a spaceThe destructor method frees a space before executingAn object borrowed the resources of the operating system, but also through the destruction
1. Basic data Type (INT,BOOL,STR)int integerThe STR string. Generally do not store large amounts of dataBOOL Boolean value. Used to judge. True, FalseList of lists. For storing large amounts of data, [] indicates. It can be loaded with various data
Naming conventions for Python variable names:
Variable names are freely combined by letters, numbers, and underscores
Variable names cannot start with a number
Cannot be a keyword in python
Variables to be descriptive
Variables
Floating 1.1 Floating Introduction
Element can be set to float left or right (does not jump out of the parent element's width)
When an element floats, it is detached from the document stream (affecting subsequent elements)
Once the
An adorner, as the name implies, is used to decorate something, a python decorator is a function used to extend function functions.Pros: Instead of changing the structure of the original function, the original function has a new functionSuch as:1
1.JSON Sequence Description: Provides 4 keywords: dumps,dump,loads,load (exactly the same as the pickle usage)Syntax: F.write (bytes (Json.dumps (dict), encoding= "Utf-8"))R=json.loads (F.read (). Decode ("Utf-8"))The dictionary is stored in a file
Interpreted languageInterpreter official with CPythonpython2.7, high repeatability, can not display Chinese, if you want to display Chinese, you need to add unicode:utf_8 in the first line of the fileDefault encoding: AscIIPYTHON3 encoded Utf_8, can
#1 creation of a list, denoted by square brackets []name=['Xiaolei','Xiaoman','Lixia','Xiaolei']#2 List of queries, by index value difference, first index to 0#The first of the countdownPrint(name[-1])#second from the
Show multiple statements on the same linePython can use multiple statements in the same row, with semicolons (;) split between statements, and here's a simple example:Instance (Python 3.0+)#!/usr/bin/python3 import sys; x = 'runoob'; sys. StdOut.
First, what is a dictionary1. The dictionary is the only type of mapping in Python, consisting of key-value pairs enclosed in {},2. The key of the element in the dictionary: must be a hash immutable data type that can be used as a key in the
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