This article is divided into two examples. The first example is a simple example of crawling a website. The second example is to capture the article list from the list page of a website and store it in the database, the database includes the article
From Python2.4, Python introduced the subprocess module to Manage Sub-processes to replace the methods of some old modules, such as OS. system, OS. spawn *, OS. popen *, popen2. *, commands. * not only can external commands be called as
This article describes how to remotely monitor a python camera. The example includes the control camera and the method for writing data to the Windows registry, you can refer to a remote monitoring program recently written in python. The main
This article mainly introduces the difference analysis of python indentation. For more information, see the following two python programs. the code is the same, but the running results are different, this is because the return indentation of the
Python always throws some exceptions when writing some network services, and the current task is terminated. use the @ decorator to write a retry Decorator. The following is an implementation example, if you want to write some network services using
Example of connecting python to mysql database: table creation, table deletion, data addition, deletion, modification, and batch insertion are provided. for details, refer to section 1. related code.
Database configuration class MysqlDBConn.
This article describes how to use BeautifulSoup to compile a crawler program to obtain the title and url of Baidu search results. for details, refer to the Java jsoup package, the BeautifulSoup library of Python should be easy to use.
The code
This article describes how to use python to parse and print data packets sent to the local machine. For more information, see tcp. py.
The code is as follows:
#-*-Coding: cp936 -*-Import socketFrom struct import *From time import ctime, sleepFrom
The easy_install tool in python is similar to pear in Php, gem in Ruby, or cpan in Perl. it is quite cool. if you want to use the easy_install tool, you may need to install setuptools first, but the cool way is to use the ez_setup.py script:
The
How is a single (one) python object referenced by multiple variables? The code below is as follows:
A = 3B =
First (), you can see at a glance:
Variable name and object. after running the value assignment statement B = a, both variables a and
For a question about setting default values and references in function parameters, this is a problem that most Pythoner may ignore. take a note for later reading. at the same time, the code for reference is as follows:
Import random, stringClass C (
Python regular expressions can be used to solve the problem of inconsistent fonts in website documents. For more information, see the fonts defined under the large framework of the website, including the font size and color, when a user publishes an
See the following source code and download it from the attachment. The code is as follows:
#-*-Coding: UTF-8 -*-From win32com. client import DispatchImport timeDef start_office_application (app_name ):# After obtaining the app here, other
Google's blog article about parsing XML files in Python does not contain XML file errors. Python file:
The code is as follows:
# Parsexml. py# In this example, the python online document has been modified and added.Import xml. parsers. expat#
Using Python for data encryption is as simple as using hashlib or hmac module for data encryption.
1. hashlibImport hashlib
# Create a hash object
Md = hashlib. md5 ()
# Md = hashlib. sha1 ()
# Md = hashlib. Shavel ()
# Md = hashlib. sha25 ()
This article mainly introduces how python uses PIL to zoom in and save network images. it involves the skills related to Python's operations on network images and is of great practical value, for more information about how to use python to scale and
This article mainly introduces how to use Python scripts to determine whether Linux runs on a virtual machine. This article describes how to determine OpenVZXenPVUML, VMwareXenHVMKVM, and VirtualBoxVirtualPC, for more information, see some foreign
This article mainly introduces a simple example of accessing the Java class from a Python program, including a short example for Android development. For more information, see
from jnius import autoclass>>> Stack = autoclass('java.util.Stack')>>>
This article mainly introduces the new string formatting method in Python3.x. This article compares the example code of the string formatting method in Python2.x and Python3.x, for more information, see Python3.x. Different from Python2.x's
The
This article mainly introduces the basic usage of the endswith () function in Python, which is the basic knowledge of Python learning. This function can be used to detect file types. For more information about the functions, see: endswith
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