首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

我所使用的Python扩展程序 for

ActivePython-3.1.3.5-win32-x86.msi bzr-2.3.1.win32-py2.6.exe CherryPy-3.2.0-py2.win32.exe dreampie-1.1.1-setup.exe Genshi-0.6.win32.exe ipython-0.10.1.win32-setup.exe matplotlib-0.99.3.win32-py2.6.exe mod_python-3.2.5b.win32-py2.3.exe mod_python-3.2.5b.win32-py2.4.exe MySQL-python-1.2.2.win32-py2.6.exe numpy-1.5.1-win32-superpack-python2.6.exe PyQt-Py2.6-gpl-4.5.4-1.exe pysqlite-2.6.0.win32-py2.6.exe python-2.7.msi pywin32-216.win32-py2.6.exe scipy-0.8.0-win32-superpack-pytho.exe setuptools-0.6c11.win32-py2.6.exe svn-python-1.6.1.win32-py2.6.exe Twisted-11.0.0.winxp32-py2.7.msi numpy scipy Markdown-2.0.win32.exe aggdraw-1.2a3-20060212.win32-py2.6.exe Tkinter wxpython pythonwin java swing pygtk pyqt ---- highlight-setup-3.4.exe ------- Psyco Pyrex PyPy Weave NumPy ctypes Tkinter wxPython PythonWin Java Swing PyGTK PyQt Paycopg MySQLdb Pygame PyXML ReportLab RepltC

02

Python权威指南的10个项目(1~5

引言:   我相信学习Python过的朋友,一定会喜欢上这门语言,简单,库多,易上手,学习成本低,但是如果是学习之后,不经常使用,或者工作中暂时用不到,那么不久之后又会忘记,久而久之,就浪费了很多的时间再自己的“曾经”会的东西上。所以最好的方法就是实战,通过真是的小型项目,去巩固,理解,深入Python,同样的久而久之就不会忘记。   所以这里小编带大家编写10个小型项目,去真正的实操Python,这10个小型项目是来自《Python权威指南》中后面10个章节的项目,有兴趣的朋友可以自行阅读。希望这篇文章能成为给大家在Python的学习道路上的奠基石。   建议大家是一边看代码,一边学习,文章中会对代码进行解释: 这里是项目的gitlab地址(全代码):

01

python图片转换pdf

#!/home/chao/anaconda3/envs/test_py2/bin/python #coding:utf-8 import os import sys from reportlab.lib.pagesizes import A4, landscape from reportlab.pdfgen import canvas from PIL import Image from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont #需要预告安装支持中文的字体,如simfang从win拷贝过来安装 def createPdf(dstpath,fileList):     img = Image.open( fileList[0].decode('UTF-8') )     c = canvas.Canvas(dstpath, img.size)#第一张图片的尺寸新建pdf     pdfmetrics.registerFont(TTFont('simfang','simfang.ttf')) #注册字体     fontheight=15     c.setFont('simfang',fontheight)     #c.drawString(100, 300, u'宋体宋体')     height=fontheight     num=1     for i in fileList:#标明本pdf的文件列表         c.drawString(fontheight,height,str(num)+"/"+str(len(fileList)))         c.drawString(fontheight+50, height, os.path.split(i)[1])         num+=1         height+=fontheight     c.showPage()     for i in fileList:         c.drawImage(i.decode('UTF-8'), 0, 0)#转换为中文路径名称打开         c.showPage()     c.save() def transferPdf(filePath,dstpath): #将一个目录下所有图片生成一个pdf     fileList=[]     #result=os.popen(" ls -l "+filePath+"| awk \'{print $9}\' | sort -t _ -k1,1 -k2n,2 ").read()     result=os.popen(" ls  "+filePath+"|  sort -t _ -k1,1 -k2n,2 ").read()     currentIndex=0     pdfIndex=0     for i in result.split("\n"):         if i.strip()!='':             print i             fileList.append(os.path.join(filePath, i))             currentIndex+=1             if currentIndex == 100:#每几页一创建                 currentIndex=0                 pdfIndex+=1                 createPdf( os.path.join(dstpath, str(pdfIndex)+".pdf") ,fileList)                 fileList=[] filePath = "/home/chao/img"#源图片文件夹 dstpath="/home/chao/tmp1"#转换出的pdf文件夹存放地址 transferPdf(filePath,dstpath)

01

Hans Rosling Charts Matplotlib 绘制

动态的图表拥有静态图表不能比拟的优势,能够有效反映出一个变量在一段时间的变化趋势,在PPT汇报演讲中是一大加分项,而在严谨的学术图表中则不建议使用。统计学家Hans Rosling在TED上关于《亚洲何时崛起》的演讲,其所采用的数据可视化展示方法可谓是近年来经典的可视化案例之一,动态的气泡图生动的展示了中国和印度是如何在过去几十年拼命追赶欧美经济的整个过程。可以说,Hans Rosling 让数据变得不再枯燥无味,使其生动的展示在大众面前,为了对这位伟大的统计学家的怀念(Hans Rosling 于2017年2月7日离开了这个世界), 本次教程将使用Python 经典的可视化库Matplotlib再现这经典的动态气泡图,或者说Hans Rosling Charts。

03
领券