ModuleIn the development of computer programs, as the program code more and more, in a file code will be more and more long, more and more difficult to maintain.In order to write maintainable code, we grouped many functions into separate files so that each file contained relatively few code, and many programming languages used this kind of organization code, in Python, a. py file is called a module.Benefits of using modulesThe greatest benefit of usin
Python common modules-time modulesYun ZhengjieCopyright Notice: Original works, declined reprint! Otherwise, the legal liability will be investigated.I. Initial TIME module1 #! /usr/bin/env python2 #_*_coding:utf-8_*_3 #@author: Yinzhengjie4 #blog:http://www.cnblogs.com/yinzhengjie/tag/python%e8%87%aa%e5%8a%a8%e5%8c%96%e8%bf%90%e7%bb%b4%e4%b9%8b% e8%b7%af/5 #Emai
a . Regular Expressionsdefinition: A method that has special meaning symbols grouped together to describe a character or string. Embedded in Python, byThe RE module is implemented, compiled into a series of bytecode, executed by the matching engine written by C. 1. Common matching mode 2. Common re-module functions(1). Re.match ()Determines whether the re matches the position of the string at the beginning. Note: This method is not an exact match. Whe
Regular Expression crawler applications (Campus beauty net) 1 Import requests 2 import RE 3 import JSON 4 #定义函数返回网页的字符串信息 5 def getpage_str (URL): 6 page_string=requests.get (URL) 7 return Page_string.text 8 9 hua_dic={}10 def run_re (URL): #爬取名字, school and favorite number of hua_str=getpage_str (URL) Hua _list=re.finditer (' Configparser ModuleThis module is suitable for Linux under the Conf configuration file format similar to the Windows INI file,
. 3, Urllib, URLLIB2 Urllib2 can accept a request object and use this to set the headers of a URL, but urllib only receives one URL. This means that you cannot disguise your user-agent string and so on. The Urllib module can provide a method for UrlEncode, which is used to generate a get query string, and URLLIB2 does not have such a function. This is why Urllib and urllib2 are often used together. (1) Urllib2.urlopen (Url[,data,timeout]) is used to obtain Web content (2) urllib2. Response (U
Web Crawl
Web sites use HTML descriptions, which means that each Web page is a structured document. Sometimes it is useful to get data from it while maintaining its structure. Web sites do not always provide their data in an easy-to-handle format, such as CSV or JSON.
This is the time for the web to crawl out. Web crawling is the practice of using a computer program to collect and organize Web page data into the desired format while preserving its structure.
lxml and requestslxml (http://lxml.
The examples in this article describe the Python creation module and the method of module import. Share to everyone for your reference. The specific analysis is as follows:
The Python Learning manual reads:
Define modules, just use a text editor, enter some Python code into the text, and then save with a. py suffix n
There are a lot of places to use random characters, such as login site random verification code, through the random module can easily generate random stringImport Randomprint (Random.randrange (1, ten)) # Returns a random number between 1-10, excluding 10print (Random.randint (1, ten)) # Returns a random number between 1-10, including 10print (Random.randrange (0, 2)) # randomly selects even print (random.random) # between 1 and 100 to return the random floating-point print ( Ra
, Tm_isdst=-1)Print(fansik.tm_year) execution results:2017ImportdatetimePrint(Datetime.datetime.now ()) Implementation results:2017-10-16 18:27:03.256569Random moduleImportRandomPrint(Random.random ())#random number from 0 to 1:0.06054267487515341Print(Random.randint (1, 9999))#random numbers from 1 to 9999, including 1 and 9999Print(Random.randrange (1, 9999))#random number from 1 to 9999, not including 9999Print(Random.choice ('Fansik'))#a character in a random FansikPrint(Random.choice (['Fan
to the mysql database in zope.PyGTK-GTK + Library Used for python GUI program development. GTK is the library used to implement GIMP and Gnome. With it, you can confidently try making your own Photoshop.PyQt-the Qt development library for python. QT is the database that implements the KDE environment. It consists of a series of modules, including qt, qtcanvas, q
to the current namespace; however, this statement should be used with caution.Positioning module:
When a module is imported, it is searched by the Python interpreter in the following sequence modules:
Current Directory
If this module is not found, search for each directory in the shell variable PYTHONPATH in Python.
If all these methods fail,
Tutorial on using third-party modules in Python, python third-party
In Python, third-party modules are installed through the setuptools tool. Python has two package management tools that encapsulate setuptools: easy_install and pi
To install IIS in Windows 7, go to "Control Panel-
Program "," Turn on or off the windows function ", after a patient wait, it turns out to be blank, and there is no Internet option.
Continue Google search and find that the "Windows modules Installer Service" needs to be started, but the system resource is insuffi
Python's advanced Application (ii) Common module learningKey points to learn in this chapter:
Definition of Python module
Time datetime Module
Random module
OS Module
SYS module
Shutil Module
Configparser Module
Shelve module
XML processing
Re-regular expression
I. Definition of the Python moduleC language Programming experience of friends know that in C lan
Use Python to compile the basic modules and framework Usage Guide for crawlers, and use guide for python
Basic modulePython crawler, web spider. Crawls the website to obtain webpage data and analyzes and extracts the data.
The basic module uses urllib, urllib2, re, and other modules.
Basic usage, for example:
(1) Perfo
finished installing, it is best to ensure that(Method II). Install Setuptools with the full installation packageOf course, users can also install them directly using the Setuptools release version. This is also a handy way for users who use Windows, and the official package management warehouse for many Linux distributions contains a version of Setuptools. For example, if you're using Ubuntu like I do, installing setuptools is simply doing the follow
, programs; I guess it should be "programer", programmer-Translator) Learn how to modify or replace a module search directory. It is important to note that because these directories contain scripts that run in the search path, these scripts should not have the same name as the standard modules, or Python will attempt to load these scripts as modules when importin
intermediate state of the python converter. When you input this module from another program next time, The. PyC file is very useful-it will be much faster, because the processing required by some input modules has been completed. In addition, the files compiled by these bytes are not related to the platform. So now you know what the. PyC files actually are.
From .. Import StatementIf you want to directly
PIL and pythonpil in common Python modules
Official Website:Http://www.pythonware.com/products/pil/index.htm
Python Imaging Library (PIL)
The Python Image Library (PIL) adds the image processing function to your Python interpreter. This library supports multiple file forma
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.