Python Basic Tutorial Notes-Item 2-format good picture-day2

Source: Internet
Author: User

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

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.