Use regular expressions in python
1. Matching characters
The metacharacters in the regular expression are. ^ $ * +? {} [] \ | ()
The matching characters are in the following modes:
\ D match any number
\ D match any non-digit
\ S matches any blank
1. Install geoip c library first
geoip c library >= 1.4.6 installed on your machine. >= 1.4.6 installed on your machine.
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.7.tar.gztar -xvzf GeoIP-1.4.7.tar.gzcd GeoIP-1.4.7./confiuremake
''' [Program 81] Question: 809 *?? = 800 *?? + 9 *?? + 1 where ?? Two digits, 8 *?? The result is two digits, 9 *?? The result is 3 digits. Please ?? Represents two digits, and 809 *?? . 1. program Analysis: 2. program source code this program is
I started to learn Python some time ago. I never thought of any good small projects that I could do. I was so anxious that I had to find a way to crawl Sina Weibo, A simple statistical item for crawling data. At first, I thought I had learned some
The Python logging module is a new feature introduced in 2.3 to handle log management during program running.Share some common classes and module-level functions of this module.
Module-level functionsLogging. getLogger ([name]): returns a logger
8.3 use the binary data record layout
The Struct module provides the pack () and unpack () methods to process binary formats with variable lengths. The following example shows how to use the title information loop in a zipfile that does not use the
8.2 Template
The String module contains a widely used class, which provides simple syntax support for end-user editing. This allows users to customize their applications without modifying the applications.
This format uses a placeholder name in
1. In-situ sorting: the sort () method is used to sort data in the specified order and then replace the original data with the sorted data (the original order is lost), for example:
Copy codeThe Code is as follows:>>> Data1 = [6,432, 22,896, 42,677,
Encapsulation is a process of converting a Python data object into a byte stream. unblocking is an encapsulation inverse operation that converts byte files or byte objects into Python data objects, do not unseal data from trusted data sources. It
Requirements: Create text files with the names of james, julie, mikey, and sarah to store their respective scores. The time format is accurate to minutes. The shorter the time, the better the score, output the first three best scores for each
Let's talk about the following ideas:
Source image-> grayscale-> map to the specified Character Sequence Based on the pixel brightness-> output.The more characters, the more character changes. Better results.If you create a character Painting Based
Now that you can use python to parse rss, we can also take a look at it to generate rss.
In fact, it is very simple, just to generate a special xml document.
Here I use PyRss2Gen, which is easy to use. You can see the Code as follows:
1 import
Although today's blogs are not as popular as those of the past few years, RSS is still very creative and practical. RSS is a simple XML format used to distribute summaries of content on websites. It can be used to share a variety of information.
The document is as follows:
# Name, age, score
Tom, 12, 86
Lee, 15, 99
Lucy, 11, 58
Joseph, 19, 56
The first column is name, the second column is age, and the third column is score)
Now, write a Python program,
1) read files
2) print the following
Copy codeThe Code is as follows:# OS ModuleOS. sep can replace the path separator specified by the operating system. '\' In windows '\\'The OS. name string indicates the platform you are using. For example, for Windows, it is 'nt ', and for
This article shows the blog posts written by vamei to the bloggers.
1. type () can display the parameter type, for example, a = 12 type (a) is int
2. the basic type of python is int float bool string such as int: I = 1, float: f = 12.5, bool: B =
1. len (mapping) returns the ing length (number of key-value pairs)
2. hash (obj) returns the hash value of obj.
>>> myDict = {'name':'earth', 'port':'80'}>>> len(myDict)2>>> hash('name')15034981
3. dict. copy () returns a copy of the Dictionary
This article describes how to organize statements into functions, the concept of parameters, and their usage in programs.
URL: http://www.cnblogs.com/archimedes/p/python-abstract.html.
Create a function
The built-in callable function can be used to
Sequence
Data structure: a collection of data elements that are organized together in a certain way. These data elements can be numbers or characters,It can even be another data structure.
In python, the most basic data structure is sequence.
Each
6.5.1 multi-Inheritance
Python also supports multiple inheritance forms. A class that can inherit multiple base classes is defined as follows:
Class DerivedClassName (Base1, Base2, Base3 ):
.
.
.
In most cases, you can consider the property
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