Server
#! /Usr/bin/env python
Import socket
Import time
Host =''
Port = 99999
S = socket. socket (socket. AF_INET, socket. SOCK_STREAM)
S. bind (host, port ))
S. listen (2)
While 1:
Conn, addr = s. accept ()
#---------------
Print 'got connection
:Download
Paste v0.2 code backup
#!/usr/bin/env python""" A pure python ping implementation using raw socket. Note that ICMP messages can only be sent from processes running as root. Derived from ping.c distributed in Linux's netkit. That
In fact, it is very easy to configure python in linux.
1. Check whether python has been installed on your linux server.
Enter the following command line:
Python-V
If the version information is displayed, it indicates that python has been installed
[Root @ localhost Python-2.7.5] # pythonPython 2.4.3 (#1, Jun 11 2009, 14:09:58) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2Type "help ", "copyright", "credits" or "license" for more information. >>>
Just make a soft connection.
[Root @
Let's look at the example:Copy codeThe Code is as follows:#! /Usr/bin/python#-*-Coding: UTF-8 -*-From bs4 import BeautifulSoupHtml_doc = """ The Dormouse's story The Dormouse's story Once upon a time there were three little sisters; and their
Copy codeThe Code is as follows:# Set a as a stringImport timeA = "10:00:00"
# In the intermediate process, strings must be converted to time arrays.Time. strptime (a, '% Y-% m-% d % H: % M: % s ')> Time. struct_time (tm_year = 2011, tm_mon = 9, tm_
Copy codeThe Code is as follows:A = 3B =
First (figure 1). You can see it at a Glance:
Variable name and object. After running the value assignment statement B = a, both variables a and B point to the memory space of object 3.If a = 'python' is
Install the corresponding library. I use PyV8.
Note that the function written in it must be enclosed ().
Copy codeThe Code is as follows:Import PyV8
Class Test ():
Def js (self ):
Ctxt = PyV8.JSContext ()
Ctxt. enter ()
Func = ctxt. eval ('''
Copy codeThe Code is as follows:# Encoding: UTF-8Import threadImport time# A function used for execution in a threadDef func ():For I in range (5 ):Print 'func'Time. sleep (1)# End the current thread# This method is equivalent to thread. exit_thread
This is a question that comes to mind when I look at lambda expressions today. We all know that the ternary operators (? :) Is a very useful statement,
About the ternary operators in C
Expression 1? Expression 2: expression 3
So how should we
RPC is short for Remote Procedure Call. It is a Remote method Call technique that calls a process (method) on a local machine, this process is also known as "Distributed Computing". It is a technology invented to improve the interoperability between
Copy codeThe Code is as follows:#-*-Coding: UTF-8 -*-
Class Heap (object ):
@ ClassmethodDef parent (cls, I ):"Parent subscripts """Return int (I-1)> 1 );
@ ClassmethodDef left (cls, I ):"Left son subscript """Return (I
@ ClassmethodDef right (cls,
The main functions are implemented in the copyFiles () function as follows:
Copy codeThe Code is as follows:Def copyFiles (src, dst ):SrcFiles = OS. listdir (src)DstFiles = dict (map (lambda x: [x, ''], OS. listdir (dst )))FilesCopiedNum = 0# Copy
Copy codeThe Code is as follows:Import socketImport re
'''Guangdong Provincial Authority Entry-Exit Government Affairs Service Network Passport, pass handling progress query.The analysis URL is formatted as
Python is outstanding
However, this is a very ambiguous sentence. What does "Python" mean? Is it an abstract interface of Python? Is CPython a general implementation of Python? Do not confuse CPython with Cython )? Or does it mean anything else?
I did not care about the comparison between Python and Java. However, I was amazed at the author's point of view. Since I started using Python, I have never been able to express the wonderful experience it brings to me in words. Compare other
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