The object that can be used for the For loop is called an iterative object (iterable), and the object can be iterated into:1. Collection data type: List, Turple, Dict, set, dir, etc.2.generator, including: Generator and generator functionsAn object
Recently in the study of Python, easy to make some records, to facilitate later review#字符串是不可再改变的序列Aa= ' ABCD '#aa [2:]= ' FF ' #报错, not directly assignable#字符串格式化: Use the format operator, or percent%, to implementprint ' Price of Aggs: $%d '%42mm=
Different Python projects require a different library of dependenciesIt is recommended that you use your own virtual environment for each project. Refer to Python's three great
Variable: The program will use a lot of temporary storage data when running, this time use the variable, the name of the temporary data.Variables in Python do not need to be declared and can be used directly, and the data type of the variable is
def productor (Myid,dataqueue,num_thread_per_productor): For i in range (Num_thread_per _productor):d ataqueue.put (' producer id:%s ==> %s '% (myid,i)) def consumer (Myid,dataqueue, Stdoutlock): While true:try:data=dataqueue.get (Block=false)
Python, like other programming languages, also has three program structures. Sequential structure, select structure, loop structure.1. Sequential structureThe sequential structure executes the program in sequence and does not explain too much.2.
Variable declaration variable1 # !/usr/bin/env python 2 3 4 " Bourbon "The code above declares a variable named: Name, and the value of the variable is: "Bourbon"The role of a variable: A variable has an identity meaning, which refers to what is
List list=[], such as: member[' 1 ', 2, ' hello ', list can contain different data typesSome common ways to list:add element:Append (), insert a new element at the end of the list, such as Member.append (' Tony '),Extend (), insert a new list at the
1, locals () and Globals () are Python's built-in functions that provide a dictionary of ways to access local variables and global variables.Example code:1 defTest (ARG):2A=13b=24Data_dict = {}5 Printlocals ()6 PrintGlobals ()7 8 9 if __name_
Processes, Threads
Process: One execution of a programThreads: Basic scheduling Unit for CPUsEach process provides the resources needed to execute the program. A process has a virtual address space, execute code, open handle system
1.cat ' filename ': The role of the Linux Cat (concatenate) command is to display the contents of the file, or to connect several files.2. In Unix, everything that is annotated by #! is the path to the loader (interpreter).Like
Python sequence, Dictionary memo, and python dictionary memo
Python memo:
Sequence: List, string, and tuplesLen (d), d [id], del d [id], data in dFunction:Cmp (x, y ),Len (seq ),List (seq) creates a list based on strings,Max (args ),Min (args
The python dictionary perfectly solves the error when retrieving and deleting elements with null values in the dictionary.
Exam = {'Math': '95', 'eng ': '96', 'chn': '90', 'phy': '', 'chem ': ''}
Use the following Traversal method to delete a file:
Python methods for reading and writing files and file objects (recommended ),
1. open
After opening a file using open, remember to call the close () method of the file object. For example, you can use the try/finally statement to ensure that the
Python checks the service port survival status and generates an alarm. python is alive.
Recently, I found that the port of a Socket service in the company's testing environment is always inexplicably Down, but the service is running normally. It
Python batch scan server port 80 Status, python scan port 80
I wrote a simple Port Scan script in Python. The simple logic is as follows:
1. python DetectHostPort. py iplist.txt (stores the text of the IP address list to be scanned, one address per
Python source code for folder Network Transmission Based on the Twisted framework,
As folders may have multiple levels of directories, recursive traversal is required.
This article adopts simple protocol customization and defines five commands. 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