I. Pure AND AND OR statements1. In a pure and statement, if each expression is not false, then the last one is returned because it needs to be matched until the last one. If there is a false, then return false2. In a pure or statement, the value of
OperatorPython supports the following types of operatorsArithmetic operators
operator
Description
Example
+
Add
Two objects added a + B output result 30
-
Reducing
Abspath返回一个目录的绝对路径Return an absolute path.>>> os.path.abspath("/etc/sysconfig/selinux")‘/etc/sysconfig/selinux‘>>> os.getcwd()‘/root‘>>> os.path.abspath("python_modu")‘/root/python_modu‘BaseName返回一个目录的基名Returns the final component of a pathname>>>
Loop structure for I in range (), while, if ... else or if ... else elifPython's looping structure is largely different from other languages, with the biggest difference being that the for loop and while loop can be used with else .Usage of keyword
Referencing in Python is a very simple thing, and there are three concepts that you need to know about packages, modules, and classes. Class This is needless to say.The module corresponds to a. py file, and then Module_name is the file. The file
DescriptionStrategy refers to the means or methods adopted to achieve a certain purpose. In order to implement the software design meter, the object may use a variety of algorithms. These algorithms can change even more often. If these algorithms
Python built-in filter() functions for filtering sequencesfilter()The function returns aIteratorfilter()Also receives a function and a sequenceWhether True False the element is retained or discarded based on the return valueDef odd_iter (): n = 1
File read and write steps:1. Open FileOpen (Path, flag[, encoding][, errors])Path: Where to open the fileFlag: Open Mode' R ': Large development file in a read-only manner, with the file's descriptor placed at the beginning of the file' RB ': Open a
1, Min (): The minimum value is taken from a list, and Max () is the inverse.2, Boll (): Judging the boll value in parentheses, except 0 and false, the others are true.3, All (): Returns True if there is a value of false in the list, and False if
One: Basic use1 Uses: relational operation, de-weight2 defined by: {} separate multiple elements with commas, each element must be immutable (hash) typeEmphasize:2.1 Elements within a set must be immutable (hash-ready) types2.2 Elements in a set are
lis03=[[[' food ', ' feeds ', ' foot '], ' good ', [' Look ', ' loof ', ' like '], ' book '],[' cool ', ' we ', ' you ', ' how ']There is a list listing that requires all the elements containing two o to be taken out:Using recursive functions
February 12, 2015 15:38:52Hits: 32624List generation is a very powerful expression built into Python that generates a list.If you want to generate a list [1, 2, 3, 4, 5, 6, 7, 8, 9] You can use range (1, 10):[Python]View PlainCopy
>>>
DescriptionThe pattern motive is to implement the operation of the real object by introducing a new object (such as small picture and remote proxy object) or to use the new object as an alias of the real object, which is the proxy mode, which is the
This article is mainly for everyone in detail introduced the python2.7 to achieve the Crawler Web page data, with a certain reference value, interested in small partners can refer to
Recently just learned Python, made a simple crawler, as a simple
This article gives you a detailed share of the Python operation MongoDB detailed steps and examples of code, there is a need for friends reference to learn it.
An import Pymongo
From Pymongo import mongoclient
Two connection server port number 27017
This article mainly introduces the use of Python to implement the local file sharing method in the same network, has a certain reference value, and now share to everyone, the need for friends can refer to
This article uses Python3 to start a
This article mainly introduces the practical automation operation of Python script sharing, has a certain reference value, now share to everyone, have the need for friends can refer to
Send SH command in
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