Python pycurl library usage instance, pythonpycurl
This article describes the usage of the pycurl library in python and shares it with you for your reference.
The code of this instance allows you to read web pages from a specified website, mainly using the pycurl library.
The specific implementation method is as follows:
# Define a class CallBack: "for pycurl" def _ init _ (self): "" Constructor "self. data = "" def func (self, data): self. data = self. data + data def urls (md5, location = "", option = {}): c = pycurl. curl () f = CallBack () c. setopt (pycurl. URL, "http: // XXXXXX/getUrl. php? Key = % s "% md5) c. setopt (pycurl. WRITEFUNCTION, f. func) c. perform () c. close () return f. data
I hope this article will help you with Python programming.
Usage of help () in Python
() Is the name of the mod you want to query
Simple python: what is the problem with an instance?
Use your own python zip Library: zlib or zipfile
The last one is more advanced and advanced. For more information, see this blog.
Blog.chinaunix.net/u1/39578/showart_356627.html
==================================
Import zipfile, OS
Z = zipfile. ZipFile (filename, 'w') # note that the second parameter here is w, and the filename here is the name of the compressed package.
# Suppose you want to add all the files named testdir to the compressed package (only the files in the first-level subdirectory are added here ):
If OS. path. isdir (testdir ):
For d in OS. listdir (testdir ):
Z. write (testdir + OS. sep + d)
# Close () is required!
Z. close ()
Reference: blog.chinaunix.net/u1/39578/showart_356627.html