The remainder of this project is mainly used urllib and LinePlot.
What is urllib?
the upper interface provided by the Urllib module allows us to read data on www and ftp as if it were a local file .
Look at the code:
Import urllib print urllib.urlopen (' http://www.baidu.com '). Read ()
Execution effect:
The key point to note is the urlopen function:
Some examples of use of urlopen can be found in the links:
http://blog.csdn.net/leer168/article/details/8643103
What is LinePlot?
LinePlot is a class used to draw a line chart, where x,y,height,width is used to set the positional parameters, and data is used to set it up.
The specific usage is as follows:
From reportlab.lib import colorsfrom reportlab.graphics.shapes import *from reportlab.graphics.charts.lineplots Import Lineplotfrom reportlab.graphics Import renderpdfdrawing = Drawing (.) LP = LinePlot () lp.x = 50LP.Y = 50lp.height = 12 5lp.width = 300lp.data = [((+), (3,4)), ((5,6), (7,8)), ((9,10), (11,12))]lp.lines[0].strokecolor = Colors.bluelp.lines [1].strokecolor = Colors.redlp.lines[2].strokecolor = COLORS.GREENDRAWING.ADD (LP) Drawing.add (String (250, 150, ' Sunspots ', fontsize=14, fillcolor=colors.red)) Renderpdf.drawtofile (drawing, ' report2.pdf ', ' sunspots ')
Item 2- frame Good draw summary:
1. The main understanding of the reportlab Package, the use of this package is almost as easy as creating plain text as easily as possible to create PDF format graphics and documents ( Renderpdf.drawtofile), in which the classes learned in this project are polyline,lineplot , etc.
2. a new method of assignment is understood:
L = [
(),
(3,4),
(5,6),
(7,8)]
b = [r[1] for R in L]
Print B
Result:[2,4,6,8]
3. preliminary understanding of Urllib, mainly for network-related operations
Python Basic Tutorial Notes-Item 2-format good picture-day2