python软件开发的案例有哪些,可用于哪些开发

Python025

python软件开发的案例有哪些,可用于哪些开发,第1张

列举一些比较有名的网站或应用。这其中有一些是用python进行开发,有一些在部分业务或功能上使用到了python,还有的是支持python作为扩展脚本语言。数据大部分来自Wikepedia和Quora。

Reddit - 社交分享网站,最早用Lisp开发,在2005年转为python

Dropbox - 文件分享服务

豆瓣网 - 图书、唱片、电影等文化产品的资料数据库网站

Django - 鼓励快速开发的Web应用框架

Fabric - 用于管理成百上千台Linux主机的程序

EVE - 网络游戏EVE大量使用Python进行开发

Blender - 以C与Python开发的开源3D绘图软件

BitTorrent - bt下载软件客户端

Ubuntu Software Center - Ubuntu 9.10版本后自带的图形化包管理器

YUM - 用于RPM兼容的Linux系统上的包管理器

Civilization IV - 游戏《文明4》

Battlefield 2 - 游戏《战地2》

Google - 谷歌在很多项目中用python作为网络应用的后端,如Google Groups、Gmail、Google Maps等,Google App Engine支持python作为开发语言

NASA - 美国宇航局,从1994年起把python作为主要开发语言

Industrial Light &Magic - 工业光魔,乔治·卢卡斯创立的电影特效公司

Yahoo! Groups - 雅虎推出的群组交流平台

YouTube - 视频分享网站,在某些功能上使用到python

Cinema 4D - 一套整合3D模型、动画与绘图的高级三维绘图软件,以其高速的运算和强大的渲染插件著称

Autodesk Maya - 3D建模软件,支持python作为脚本语言

gedit - Linux平台的文本编辑器

GIMP - Linux平台的图像处理软件

Minecraft: Pi Edition - 游戏《Minecraft》的树莓派版本

MySQL Workbench - 可视化数据库管理工具

Digg - 社交新闻分享网站

Mozilla - 为支持和领导开源的Mozilla项目而设立的一个非营利组织

Quora - 社交问答网站

Path - 私密社交应用

Pinterest - 图片社交分享网站

SlideShare - 幻灯片存储、展示、分享的网站

Yelp - 美国商户点评网站

Slide - 社交游戏/应用开发公司,被谷歌收购

# 以下程序可能要安装OpenCV2.0(并编译好并配置好环境)以及Xvid解码器才能运行

# _*_coding: cp936_*_

import cv

capture = cv.CreateFileCapture("tmp.avi")

#请确保当前目录下有tmp.avi文件

fps = cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FPS)

totalFrameNumber =cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_COUNT)

frameWidth = cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_WIDTH)

frameHeight = cv.GetCaptureProperty(capture, cv.CV_CAP_PROP_FRAME_HEIGHT)

print fps, totalFrameNumber, frameWidth, frameHeight

frame = cv.QueryFrame(capture)

while frame:

cv.ShowImage('Title', frame)

frame = cv.QueryFrame(capture)

if cv.WaitKey(1000 / fps) == 27:# ESC键退出视频播放

cv.DestroyWindow('Title')

break

一个文件夹整理工具wxPython版本(不清楚软件用法情况下可以打开该软件看看界面但请不要使用里面的功能,后果自负。)

# -*- coding: cp936 -*-

# file:aa.py

import os, shutil, sys

import wx

sourceDir = ''

sourceFiles = ''

preWord = 0

def browse(event):

global sourceDir, textPreWord, textDirName

dialog = wx.DirDialog(None, u'选择待处理文件夹', style = wx.OPEN)

if dialog.ShowModal() == wx.ID_OK:

sourceDir = dialog.GetPath().strip('\"')

textDirName.SetLabel(sourceDir)

dialog.Destroy()

textPreWord.SetFocus()

def okRun(event):

global preWord, sourceDir, sourceFiles, textPreWord

preWord = int(textPreWord.GetValue())

if preWord <= 0:

wx.MessageBox(u'请正确输入前缀字符个数!', u'出错啦', style = wx.ICON_ERROR | wx.OK)

textPreWord.SetFocus()

return

sourceDir = textDirName.GetValue()

sourceFiles = os.listdir(sourceDir)

for currentFile in sourceFiles:

tmp = currentFile

currentFile = sourceDir + '\\' + currentFile

currentFile = currentFile.strip('\"')

if os.path.isdir(currentFile):

continue

targetDir = '%s\\%s'%(sourceDir, tmp[:preWord])

if not os.path.exists(targetDir):

os.mkdir(targetDir)

shutil.move(currentFile, targetDir)

wx.MessageBox(u'任务完成!', u'好消息', style = wx.ICON_ERROR | wx.OK)

def onChange(event):

global dir1, textDirName

p = dir1.GetPath()

textDirName.SetLabel(p)

app = wx.App(0)

win = wx.Frame(None, title = u'文件整理', size = (400, 450))

bg = wx.Panel(win)

btnBrowse = wx.Button(bg, label = u'浏览')

btnBrowse.Bind(wx.EVT_BUTTON, browse)

btnRun = wx.Button(bg, label = u'整理')

btnRun.Bind(wx.EVT_BUTTON, okRun)

dir1 = wx.GenericDirCtrl(bg, -1, dir='', style=wx.DIRCTRL_DIR_ONLY)

tree = dir1.GetTreeCtrl()

dir1.Bind(wx.wx.EVT_TREE_SEL_CHANGED, onChange, id = tree.GetId())

textPreWord = wx.TextCtrl(bg)

textDirName = wx.TextCtrl(bg)

textPreWord.SetFocus()

class MyFileDropTarget(wx.FileDropTarget):#声明释放到的目标

def __init__(self, window):

wx.FileDropTarget.__init__(self)

self.window = window

def OnDropFiles(self, x, y, filenames):#释放文件处理函数数据

for name in filenames:

if not os.path.isdir(name):

wx.MessageBox(u'只能选择文件夹!', '出错啦', style = wx.ICON_ERROR | wx.OK)

return

self.window.SetValue(name)

dt = MyFileDropTarget(textDirName)

textDirName.SetDropTarget(dt)

hbox0 = wx.BoxSizer()

hbox0.Add(dir1, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)

hbox1 = wx.BoxSizer()

hbox1.Add(textDirName, proportion = 1, flag = wx.EXPAND, border = 5)

hbox1.Add(btnBrowse, proportion = 0, flag = wx.LEFT, border = 5)

hbox2 = wx.BoxSizer()

hbox2.Add(textPreWord, proportion = 1, flag = wx.EXPAND, border = 5)

hbox2.Add(btnRun, proportion = 0, flag = wx.LEFT, border = 5)

vbox = wx.BoxSizer(wx.VERTICAL)

vbox.Add(hbox0, proportion = 1, flag = wx.EXPAND | wx.ALL, border = 5)

vbox.Add(wx.StaticText(bg, -1, u'\n 选择待处理文件夹路径:'))

vbox.Add(hbox1, proportion = 0, flag = wx.EXPAND | wx.ALL, border = 5)

vbox.Add(wx.StaticText(bg, -1, u'\n\n 前缀字符个数:'))

vbox.Add(hbox2, proportion = 0, flag = wx.EXPAND | wx.ALL, border = 5)

vbox.Add(wx.StaticText(bg, -1, u'\n'))

bg.SetSizer(vbox)

win.Center()

win.Show()

app.MainLoop()

#py2exe打包代码如下:

from distutils.core import setup

import py2exe

setup(windows=["aa.py"])

打包好了之后有18Mb。

一个文件内容批量替换摸查器(wxPython版本):

# _*_ coding:cp936 _*_

from string import join, split

import os

import wx

def getAllFiles(adir):

tmp = []

for parent, dirs, files in os.walk(adir):

for afile in files:

tmp.append(os.path.join(parent, afile))

return tmp

def browse(event):

dialog = wx.DirDialog(None, '选择待处理文件夹', style=wx.OPEN)

if dialog.ShowModal() == wx.ID_OK:

aDir = dialog.GetPath()

textDir.SetLabel(aDir)

dialog.Destroy()

def check():

promp.SetForegroundColour('#FF0000')

promp.SetLabel(' 搜索中...')

listFound.ClearAll()

tmp = []

files = getAllFiles(textDir.GetValue())

for filename in files:

try:

afile = open(filename, 'r')

except IOError:

print '打开文件错误。'

continue

try:

content = afile.read().decode('utf-8')

afile.close()

except:

try:

afile = open(filename, 'r')

content = afile.read().decode('cp936')

afile.close()

except:

continue

if textNeedChar.GetValue() in content:

tmp.append(filename)

listFound.InsertStringItem(0, filename)

parentDir.SetForegroundColour('#FF0000')

# parentDir.SetLabel(' 正在搜索:'+filename)

return tmp

def onFind(event):

check()

parentDir.SetLabel(' 搜索结果:')

promp.SetLabel(' 任务完成。')

wx.MessageBox(listFound.GetItemCount() and '任务完成,找到%d个文件。' % listFound.GetItemCount()

or '未找到包含"%s"的文件!' % textNeedChar.GetValue().encode('cp936'), '查找结束',

style=wx.ICON_INFORMATION | wx.OK)

def onReplace(event):

dg = wx.TextEntryDialog(bg, '替换成:', '提示', style=wx.OK | wx.CANCEL)

if dg.ShowModal() != wx.ID_OK:

return

files = check()

userWord = dg.GetValue()

#if not userWord:

#wx.MessageBox('请输入要替换为何字!', style=wx.ICON_ERROR | wx.OK)

#onReplace(event)

#return

for filename in files:

try:

afile = open(filename, 'r')

except IOError:

print '打开文件错误。'

continue

try:

content = afile.read().decode('utf-8')

afile.close()

except:

try:

afile = open(filename, 'r')

content = afile.read().decode('cp936')

afile.close()

except IOError:

print '打开文件错误。'

continue

content = content.replace(textNeedChar.GetValue(), userWord)

try:

content = content.encode('utf-8')

except:

pass

open(filename, 'w').write(content)

parentDir.SetLabel(' 替换的文件:')

promp.SetLabel(' 任务完成。')

wx.MessageBox(listFound.GetItemCount() and '任务完成,替换了%d个文件。' % listFound.GetItemCount()

or '未找到包含"%s"的文件!' % textNeedChar.GetValue().encode('cp936'), '替换结束', style=wx.ICON_INFORMATION | wx.OK)

app = wx.App(0)

win = wx.Frame(None, title='文件整理', size=(400, 450))

bg = wx.Panel(win)

btnBrowse = wx.Button(bg, label='浏览')

btnBrowse.Bind(wx.EVT_BUTTON, browse)

btnFind = wx.Button(bg, label='查找')

btnFind.Bind(wx.EVT_BUTTON, onFind)

btnFind.SetDefault()

btnReplace = wx.Button(bg, label='替换')

btnReplace.Bind(wx.EVT_BUTTON, onReplace)

textNeedChar = wx.TextCtrl(bg, value='你好')

textDir = wx.TextCtrl(bg, value='E:\Workspace\Python\Python\e')

parentDir = wx.StaticText(bg)

promp = wx.StaticText(bg)

listFound = wx.ListCtrl(bg, style=wx.VERTICAL)

class MyFileDropTarget(wx.FileDropTarget):#声明释放到的目标

def __init__(self, window):

wx.FileDropTarget.__init__(self)

self.window = window

def OnDropFiles(self, x, y, filenames):#释放文件处理函数数据

for name in filenames:

'''if not os.path.isdir(name):

wx.MessageBox('只能选择文件夹!', '出错啦', style=wx.ICON_ERROR | wx.OK)

return '''

self.window.SetValue(name)

dt = MyFileDropTarget(textDir)

textDir.SetDropTarget(dt)

hbox1 = wx.BoxSizer()

hbox1.Add(textDir, proportion=1, flag=wx.EXPAND, border=5)

hbox1.Add(btnBrowse, proportion=0, flag=wx.LEFT, border=5)

hbox2 = wx.BoxSizer()

hbox2.Add(textNeedChar, proportion=1, flag=wx.EXPAND, border=5)

hbox2.Add(btnFind, proportion=0, flag=wx.LEFT, border=5)

hbox2.Add(btnReplace, proportion=0, flag=wx.LEFT, border=5)

vbox = wx.BoxSizer(wx.VERTICAL)

vbox.Add(wx.StaticText(bg, -1, '\n 选择待处理文件夹(可拖动文件夹到下面区域中):'))

vbox.Add(hbox1, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)

vbox.Add(wx.StaticText(bg, -1, '\n\n 要替换 / 查找的文字:'))

vbox.Add(hbox2, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)

vbox.Add(promp, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)

vbox.Add(parentDir, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)

vbox.Add(listFound, proportion=1,

flag=wx.EXPAND | wx.LEFT | wx.BOTTOM | wx.RIGHT, border=5)

bg.SetSizer(vbox)

win.Center()

win.Show()

app.MainLoop()

python入门实例教程!

步骤1:这里我将简单告诉大家一个用python软件编写的一个关于货物售价折扣方面的一个计算程序,首先打开python软件。

步骤2:进入python后,会出现如图所示界面,按照图中箭头指示,先选择File选项,然后在下拉菜单中选择New file选项。

步骤3:选择完毕后,会出现一个新的界面,如图箭头和红色框指示。

步骤4:进入这个新的界面,在里面输入自己想编辑的程序,如图所示是我自己编写的一个关于货物售价折扣方面的一个简单的计算程序。

步骤5:程序输入完毕后,按照图中箭头和红色框指示,先选择Run选项,然后在下拉菜单中选择Run Module(注:除此方法外还可以点击键盘F5)。

步骤6:此时会在原界面出现如图所示的字样,这是因为我编写程序编辑好的,此时你可以输入一个数字,然后回车,它又会让你输入一个折扣,输入完即可得出最后售价结果。

步骤7:如图所示,这里我输入的原价是10,折扣是0.2,故此系统根据我编写的程序计算除了打折后的价格为2。