Use Python to write one of the simplest webserver

Import socketdef handle_request (client):BUF = CLIENT.RECV (1024)Client.send ("http/1.1 ok\r\n\r\n")Client.send (' hello world ')def main ():Sock=socket.socket (Socket.af_inet,socket. SOCK_STREAM)Sock.bind (' 192.168.68.128 ', 8006)Sock.listen

Python Basics "Eighth article": Anatomy of Recursive functions

Recursive functionsIf the function contains a call to itself, the function is a recursive function!Let's start with the Fibonacci sequence: The Fibonacci sequence becomes the Golden section, showing the form 0, 1, 1, 2, 3, 5, 8, 13, 21, and

Python----------string

String * Number-------------print string number of times"Echo" * 3 ' Echoechoecho '  Strings are added--------------strings are joined togethers = ' Hello ' + ' world's ' Hello World 'String length---------------------lenSplit: S.splitS.split ()

Python Group ()

In a regular expression, group () is used to present a string that is intercepted by a packet , () to groupImport rea = "123abc456" Print Re.search ("([0-9]*) ([a-z]*] ([0-9]*)", a). Group (0) #123abc456, return to overall print re.search (" ([0-9]

Python View function code content

Method 1: Use Help (Random)Import random>>> Help on module Random:name - random variable generators. file c:\python27\lib\random.py # files store locationMethod 2: Use random.__file__ to view the location, and then open the file with the

Python smtp Send mail

There is a need to automatically send mail in the business, there is no function to add attachments.At the same time, also solved the message in Chinese garbled situation.Directly on the code:Import SmtplibFrom Email.mime.text import MimetextdefMail_

The first chapter of Python introduces -1.python features.

A Python featuresOpen Source Freescripting language, parsing executionCross-platformHigh-level languages, object-oriented, extensible, and portable for use on different platforms (because Python is written in C , and because of the portability of

Python: Statistical system remaining memory

#!/usr/bin/pythonWith open ('/proc/meminfo ') as FD:For line in FD:If Line.startswith (' Memtotal '):Total = Line.split () [1]ContinueIf Line.startswith (' Memfree '):Free = Line.split () [1]Breakfreemem = Int (free)/1024.0Totalmem = Int (total)/1024

Python notes: subtraction, formatting strings

[[email protected] day01]# python 3.pyPlease input a number:1Please input a number:23-1201 + 2 = 31-2 = 11 * 2 = 21/2 = 0[email protected] day01]# cat 3.py#!/usr/bin/pythonNUM1 = input ("Please input a number:")num2 = input ("Please input a number:")

Introduction to Python Package management tools

Common package management tools and relationshipsSetuptools-->distributeEasy_install-->pip1, distributeDistribute is an enhancement to the standard library Disutils module, and we know that disutils is primarily used to package and distribute

Python upgrade Yum cannot be used to resolve

1. System version[[Email protected] ~] # cat/etc/issueCentOS release 6.4 (Final) Kernel \ r on an \m2. System default Python version[[Email protected] ~] # Python-vpython 2.6.6 3. Error message[[Email protected] ~]#YumThere is a problem importing

Python re.compile (? p<name>)

The regular can also match ... Geeksquiz Web site to provide code questions, can be used to self-test a language mastery situation, today to do Python's topic has an interesting discovery-the original can also write this >>>Sentence = ' Cats is fast

A brief introduction to the use of "_" in Python

0. BackgroundThe underscore "_" in Python is much more frequent than other mainstream languages, and it has its own unique use in Python. This article focuses on: the use of underline in Python common sense.1. Single underline-encapsulates a name

PYTHON+OPENCV implementation of Gaussian smoothing filter

Function:Create two sliders to control the size of the Gaussian kernel and σ The size of this program is changed on the threshold partition of the program. The threshold splitting program is in thisNote: because σ=0

Python sequence 2-string

Python sequence 2-basic operation of string stringsStrings are a string of characters enclosed in single or double quotation marks, which is the most basic type of data. Its basic operations include: create assignment, access, change, delete . An

Statistical learning methods-Logistic regression notes and Python source code

Logical regression (logistic regression)Logistic regression is a classical classification method in statistical learning. It is more used on the two classification {0,1} issue.Definition 1:Set X is a continuous random variable, and x obeys the

Python Deletes the installed module

The previous article describes how to use the Distutils module to create a bundle, then after installing the module, how to delete it, the specific steps are as follows:[[email protected] ansible]# ls-l/usr/share/kel-rw-r--r--1 root root 9 09:23/usr/

Automatically send mail using Python

#-*-Coding:utf-8-*-From Email.mime.text import MimetextFrom Email.header Import HeaderImport Smtplibdef send_mail (file_new):f = open (File_new, ' RB ')Mail_body = F.read ()F.close ()msg = Mimetext (mail_body, ' html ', ' Utf-8 ')msg[' Subject ' =

(Python learning 4) List Object

1. Pylistobject Objecttypedef struct { Pyobject_var_head * *Ob_item; py_ssize_t allocated; } Pylistobject; # how to ask Hovertree.comThe obsize in Pyobject_var_head represents the number of elements that the list object

Python list and metadata group, python list

Python list and metadata group, python list 1. List 1.1 Basic operations on the list: Index, slice, append, delete, length, slice, cycle, and contain>>> Name_list = ['Alex ', '65brother', 'tenglanc'] # initialize a list >>> type (name_list) #

Total Pages: 4013 1 .... 3879 3880 3881 3882 3883 .... 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.