python常用50个模块

python常用50个模块


Python具有强大的扩展能力,我列出了50个很棒的Python模块,包含几乎所有的需要:比如Databases,GUIs,Images, Sound, OS interaction, Web,以及其他。

Graphical interface wxPython http://wxpython.org
Graphical interface pyGtk http://www.pygtk.org
Graphical interface pyQT http://www.riverbankcomputing.co.uk/pyqt/
Graphical interface Pmw http://pmw.sourceforge.net/
Graphical interface Tkinter 3000 http://effbot.org/zone/wck.htm
Graphical interface Tix http://tix.sourceforge.net/

Database MySQLdb http://sourceforge.net/projects/mysql-python
Database PyGreSQL http://www.pygresql.org/
Database Gadfly http://gadfly.sourceforge.net/
Database SQLAlchemy http://www.sqlalchemy.org/
Database psycopg http://www.initd.org/pub/software/psycopg/
Database kinterbasdb http://kinterbasdb.sourceforge.net/
Database cx_Oracle http://www.cxtools.net/default.aspx?nav=downloads
Database pySQLite http://initd.org/tracker/pysqlite

MSN Messenger msnlib http://auriga.wearlab.de/~alb/msnlib/
MSN Messenger pymsn http://telepathy.freedesktop.org/wiki/Pymsn
MSN Messenger msnp http://msnp.sourceforge.net/
Network Twisted http://twistedmatrix.com/
Images PIL http://www.pythonware.com/products/pil/
Images gdmodule http://newcenturycomputers.net/projects/gdmodule.html
Images VideoCapture http://videocapture.sourceforge.net/

Sciences and Maths scipy http://www.scipy.org/
Sciences and Maths NumPy http://numpy.scipy.org/
Sciences and Maths numarray http://www.stsci.edu/resources/software_hardware/numarray
Sciences and Maths matplotlib http://matplotlib.sourceforge.net/

Games Pygame http://www.pygame.org/news.html
Games Pyglet http://www.pyglet.org/
Games PySoy http://www.pysoy.org/
Games pyOpenGL http://pyopengl.sourceforge.net/

Jabber jabberpy http://jabberpy.sourceforge.net/

Web scrape http://zesty.ca/python/scrape.html
Web Beautiful Soup http://crummy.com/software/BeautifulSoup
Web pythonweb http://www.pythonweb.org/
Web mechanize http://wwwsearch.sourceforge.net/mechanize/

Localisation geoname.py http://www.zindep.com/blog-zindep/Geoname-python/

Serial port pySerial http://pyserial.sourceforge.net/
Serial port USPP http://ibarona.googlepages.com/uspp

Parallel Port pyParallel http://pyserial.sourceforge.net/pyparallel.html

USB Port pyUSB http://bleyer.org/pyusb/

Windows ctypes http://starship.python.net/crew/theller/ctypes/
Windows pywin32 http://sourceforge.net/projects/pywin32/
Windows pywinauto http://www.openqa.org/pywinauto/
Windows pyrtf http://pyrtf.sourceforge.net/
Windows wmi http://timgolden.me.uk/python/wmi.html

PDA/GSM/Mobiles pymo http://www.awaretek.com/pymo.html
PDA/GSM/Mobiles pyS60 http://sourceforge.net/projects/pys60

Sound pySoundic http://pysonic.sourceforge.net/
Sound pyMedia http://pymedia.org/
Sound FMOD http://www.fmod.org/
Sound pyMIDI http://www.cs.unc.edu/Research/assist/developer.shtml

GMail libgmail http://libgmail.sourceforge.net/
Google pyGoogle http://pygoogle.sourceforge.net/
Expect pExpect http://pexpect.sourceforge.net/
WordNet pyWordNet http://osteele.com/projects/pywordnet/
Command line cmd http://blog.doughellmann.com/2008/05/pymotw-cmd.html
Compiler backend llvm-py http://mdevan.nfshost.com/llvm-py/
3D VPython http://vpython.org


import serial
ser = serial.serial("com3", 15200)
ser.close()
ser.open()

while 1 == 1
    data = ser.readline()
    print(data)

serial模块介绍

  • serial模块安装

    pip install pyserial

  • 常用的方法函数

    • 导入串口模块 import serial;
    • 打开串口 ser = serial.Serial(端口名称,…其他参数),ser.open()方法可以在close之后再次打开相应端口;
    • 关闭串口ser.close();
    • 通过串口写入 ser.write(b”),参数需要使用字节bytes类型,如果是str类型,则可以使用encode(‘utf-8’)的方式进行转换;
    • 读取模块信息的方法如下,x = ser.read()读取一个字节,x=read(n)读取n个字节,readline()可以用来读取一行。
  • 查看COM口工具

    python -m serial.tools.list_ports -v,可以列出所有串口名称及属性。

  • Serial参数说明

    • port端口名字,windows下为’COM1’等;
    • baudrate (int)波特率,可以设置的范围9600到115200;
    • bytesize为每个字节的比特数,设置值为FIVEBITS, SIXBITS,SEVENBITS, EIGHTBITS 5-8比特;
    • parity设置校验位PARITY_NONE, PARITY_EVEN,PARITY_ODD PARITY_MARK, nPARITY_SPACE,用来设置校验位;
    • stopbits停止位,用来指示字节完成,可以选择的设置STOPBITS_ONE,
      STOPBITS_ONE_POINT_FIVE, STOPBITS_TWO;
    • write_timeout(float) 写入超时设置;
    • xonxoff (bool)软件流控开关;
    • dsrdtr (bool)硬件DSR/DTR流控开关。
    • 关于UART流控两线方式没有硬件流控,四线方式采用DSR、DTR进行流控,而RS232标准中可以有DSR、DTR的流控方式。RTS-request to send; CTS- clear to send;DSR-data set ready;DTR-Data Terminal Ready。

对于很多简单应用,要实现的功能可能就是对输入几个数字进行打包发送到串口,这样用python解析xml文件自动生成界面或许是很不错的选择。解析xml可以参考Python XML解析

本文转载自“python常用50个模块”

猜你喜欢

转载自blog.csdn.net/helaisun/article/details/80670399