The code is as follows:
#-*-Encoding:utf-8-*-'''Created on 2014-4-24
@author: Leon Wong'''
Import Urllib2Import UrllibImport reImport timeImport OSImport UUID
#获取二级页面urldef findUrl2 (HTML):Re1 = R ' http://tuchong.com/\d+/\d+/|http://\w+ (?
Cookies are used for server implementation sessions, user login and related functions for state management. To install the Cookie,http server on the user's browser, add an HTTP header that resembles the following to the HTTP response:
The code is
Recently took over more and more things, release and operation of the work is quite mechanical, coupled with the frequency is quite high, resulting in time wasted or a lot of advantages. Fix bugs What, test, submit repository (2 minutes), SSH to
File Operation Example
The code is as follows:
#输入文件f = open (R ' D:\Python27\pro\123.bak ')#输出文件FW = open (R ' D:\Python27\pro\123e.bak ', ' W ')#按行读出所有文本lines = F.readlines ()num =-1For line in lines:str = ' @SES/%i/'%numline = Line.replace ('
Intranet hosts are automatically assigned IP address, sometimes need to look under the IP in use, wrote a simple script.
Linux and Windows can be used, multi-threaded to ping1-255 all addresses, inefficient, about 2 minutes. Just make it and use it.
1. Two ways to get the current time:
The code is as follows:
Import Datetime,timenow = Time.strftime ("%y-%m-%d%h:%m:%s")Print nownow = Datetime.datetime.now ()Print now
2. Get the last day of the month minus 1 days on the first day of the month
Let's describe the plot of this article: Suppose you want to run a process on the local machine, and some of the program logic is somewhere else. Let us especially assume that this program logic will be updated from time to times, and that you want
Import OS
Os.os.listdir (PATH)
And then one of the analysis files and directories
With the clever combination of the DOS command dir, it is easy to do this, look at the example
Get all file methods under directory
cmd = "dir/a-d/b"
List_file =
This example describes how Python arranges pictures and outputs in a ring form. Share to everyone for your reference. The specific analysis is as follows:
This code can customize a blank artboard and then arrange the specified picture in a doughnut-
1. Self, CLS is not a keyword
Inside Python, self, the CLS is not a keyword, you can use any variable you write instead of implementing the same effect.
Code 1
The code is as follows:
Class MyTest:myname = ' Peter 'def sayhello (hello):Print "Say
When I met one of the founders of the SimPy bag, Klaus Miller, I learned about the package from him. Dr. Miller has read several cute Python columns that suggest techniques for implementing semi-collaborative routines and "lightweight" threading
This example describes how Python uses ARP spoofing to forge a gateway. Share to everyone for your reference. The implementation method is as follows:
#coding: Utf-8 ' arp spoofing LAN PC, sending forged gateway Mac to ARP reply of gateway to PC
The example in this article describes the room portion of Python that gets two array intersection, set, and difference sets. Share to everyone for your reference. Specific as follows:
1. Get the intersection of two lists
#方法一: A=[2,3,4,5]b=[2,5,
This paper describes the implementation of KNN algorithm Python and the method of simple digital recognition. Share to everyone for your reference. Specific as follows:
KNN algorithm algorithm Advantages and disadvantages:
Advantages: High accuracy,
Recently encountered a scenario, is to generate and send the server usage report on a regular basis, according to the statistics of different dimensions, involving the operation of Python to Excel, surfing the Internet, mostly similar, and not
The example in this article describes how Python implements downloading pictures from a feed. Share to everyone for your reference. Specific as follows:
This code is implemented based on Python 3.4, and Python2. X is a lot different than that.This
Today, when I write a script that automatically backs up all the directories under the specified directory under Linux, I get a problem because I need to back up the directory, so I need to determine if the scanned file is a directory, and when I
This paper describes the common methods and efficiency comparisons of Python merging two dictionaries. Share to everyone for your reference. The specific analysis is as follows:
The following code gives an example of 5 ways to merge two
Dictionaries consist of pairs of keys and their corresponding values (which make key-value pairs an item), separated by a colon (:) between each key and its value, separated by commas (,), and the entire dictionary enclosed by a pair of curly braces.
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