Python stack and queue

1. python implements the Stack. You can first write the stack class to the file stack. py, use from Stack import Stack in other program files, and then use the stack. The stack. py program is as follows: Class Stack (): def _ init _ (self, size):

Python afternoon tea (1)

In front of the article: it takes more than 15 minutes (the last large size is enough) to give a general impression on python. This article is based on the pattern of an article by Chen Hao DANIEL: http://coolshell.cn/articles/42539.html.w.bicycle

Introduction to python Data Structure Tree and binary tree

1. Tree Definition Tree structure is an important non-linear structure. A tree structure is a structure with branches and hierarchical relationships between nodes. It is very similar to a tree in nature.Recursive definition of the tree:A Tree is a

Python BASICS (5)-dictionary

A dictionary consists of multiple keys and their corresponding values (the key-value pair is an item). Each key and its value are separated by a colon, items are separated by commas (,), and the entire dictionary is enclosed by a pair of braces. The

Example of proxy mode in Python Design Mode

A common way to overturn a wall is to use a Proxy. The basic process is as follows: Browser proxy server Server If the browser request does not reach the server, or the server cannot respond to the browser, we can set to pass the browser request

Python 6_encapsulation and inheritance (1)

  Let's look at a simple example: # Author liygcheng 2014-04-04 # object-oriented python class Animal (): def _ init _ (self): self. _ name = Animalprint (self. _ name) def accessMethod (self): print (I am a animal, and my name is :) print (self. _

Python-based apahce website log analysis example

An example of script maintenance is a bit messy, just as an instance, demonstrating how to quickly use the tool to quickly achieve the goal:Application: shell and python data interaction, data capturing, and Code Conversion Copy codeThe Code is as

Switch the hosts file using python

During development or testing, you often need to switch the hosts. If there are many hosts, It is cumbersome to frequently open the hosts file and add a comment (#) to the address, and then remove the comment. Of course, SwitchHosts can help us

Introduction to the design mode for beginners of Python (1)

Have you ever wondered what the design pattern is? This article shows why the design mode is so important. It uses several Python examples to demonstrate why the design mode is required and how to use it. What is the design pattern? The design

Python Data Structure-Implementation of Binary Trees

1. Binary Tree Each node in a binary tree cannot have more than two sons. 1.1 Binary Tree List Implementation For example, the binary tree list can be used to indicate: Tree = ['A', # root ['B', # Left subtree ['D', [], [], ['E', [], [], ['C', #

Django Performance Optimization

2. Use a separate static file server 3. Disable KeepAlive (if the server does not provide static file services, such as large file downloads) 4. Use 5. Use to load associated table data 6. Filter unnecessary fields for query 7. Use 8. Load the

Example of python Dynamic Monitoring log Content

Generally, log files are generated on a daily basis. The program judges the file generation date and current time, and replaces the monitored log files.The program is just a simple example, monitoring test1.log 10 seconds, to monitoring

Use smtplib and email to encapsulate the python mail sending module class sharing

Copy codeThe Code is as follows:#! /Usr/bin/python# Encoding = UTF-8# Filename: send_email.pyFrom email. mime. image import MIMEImageFrom email. mime. multipart import MIMEMultipartFrom email. mime. text import MIMETextImport smtplib Class SendEmail:

Simple example of using python to implement socket client and server

Copy codeThe Code is as follows:Import socket# Socket communication ClientDef client ():Mysocket = socket. socket (socket. AF_INET, socket. SOCK_STREAM)Mysocket. connect ('2017. 0.0.1 ', 127 ))Mysocket. send ('hello ')While 1:Data = mysocket. recv (1

Connect to mysql using python and submit mysql transaction examples

Copy codeThe Code is as follows:#-*-Coding: UTF-8 -*-Import sysImport MySQLdbReload (sys)Sys. setdefaultencoding ('utf-8 ')Class DB (object ):Def _ init _ (self, host = '192. 0.0.1 ', port = 127, user = 'root', passwd = '2016', database = ''):Self. _

Python RotatingFileHandler Bug

The Python library is very powerful and can basically find all the lib we need. The logging module is a log record library in Python. It draws on the idea of the LOG4J module in Java and can be conveniently used to record software execution logs.

[Python] Importing Python Modules

Introduction TheImportAndFrom-importStatements are a constant cause of serious confusion for newcomers to Python. Luckily, once you 've figured out what they really do, you'll never have problems with them again. This note tries to sort out some of

Example of implementing socket port redirection in python

You can easily enable sharing on port 12345. The effect is as follows: To implement the desired function, you only need to redirect the port. The Code is as follows: Copy codeThe Code is as follows:#! /Usr/bin/python'''File: redirect. pyAuthor: Mike'

SQL Server access using python

I recently encountered the problem of accessing SqlServer through Python. Here is a summary. 1. Configure Python to access Sqlserver in Windows Environment: Windows 7 + Sqlserver 2008 1. Download and install pyodbc :

How python processes cookies

To install cookies in your browser, the HTTP Server adds an HTTP header similar to the following to the HTTP response: Copy codeThe Code is as follows:Set-Cookie: session = 8345234; expires = Sun, 15-Nov-2013 15:00:00 GMT; path =/; domain =

Total Pages: 4013 1 .... 2050 2051 2052 2053 2054 .... 4013 Go to: GO

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.