返回顶部
首页 > 资讯 > 后端开发 > Python >python-object-one-ne
  • 225
分享到

python-object-one-ne

pythonobjectne 2023-01-31 01:01:18 225人浏览 独家记忆

Python 官方文档:入门教程 => 点击学习

摘要

#!/usr/bin/env python2.6 # Written by Tony.yang # 2012-12-28 from urllib import urlopen from repor

#!/usr/bin/env python2.6
# Written by Tony.yang
# 2012-12-28

from urllib import urlopen
from reportlab.graphics.shapes import *
from reportlab.graphics.charts.lineplots import LinePlot
from reportlab.graphics.charts.textlabels import Label
from reportlab.graphics import renderpdf

URL = 'Http://www.swpc.noaa.Gov/ftpdir/weekly/Predict.txt'
COMMENT_CHARS = '#:'

# Create a Drawing mode
drawing = Drawing(400, 200)
data = []

for line in urlopen(URL).readlines():
        if not line.isspace() and not line[0] in COMMENT_CHARS:
                data.append([float(n) for n in line.split()])

# define property
pred = [row[2] for row in data]
high = [row[3] for row in data]
low = [row[4] for row in data]
times = [row[0] + row[1]/12.0 for row in data]

#
lp = LinePlot()
lp.x = 50
lp.y = 50
lp.height = 125
lp.width = 300
lp.data = [zip(times, pred), zip(times, high), zip(times, low)]
lp.lines[0].strokeColor = colors.blue
lp.lines[1].strokeColor = colors.red
lp.lines[2].strokeColor = colors.green

drawing.add(lp)
drawing.add(String(250, 150, 'Sunspots', fontSize=14, fillColor=colors.red))

renderPDF.drawToFile(drawing, 'Tony_report_new.pdf', 'Sunspots')
 

--结束END--

本文标题: python-object-one-ne

本文链接: https://lsjlt.com/news/183838.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作