python
文章平均质量分 75
Jack_Lpz
Jack_Li style
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
正则表达式的应用
#!/usr/bin/python#-*- coding:utf8 -*-import re#现在讲讲正则表达式#这是一种字符串的高级语法规则string = "Hello, This is a test from jack"#首先匹配头部 Hello#使用^print re.findall(r"^Hello",string)print re.f原创 2014-09-18 09:49:21 · 537 阅读 · 0 评论 -
python操作数据库
#!/usr/bin/python#-*- coding:utf8 -*-#主要演示python操作mysql数据库#首先建立数据库#数据库的基本操作就不说了#create table Student#(# number int primary key,# name char(10) not null,# age int,# sex ch原创 2014-09-27 20:53:41 · 472 阅读 · 0 评论 -
python异常
#!/usr/bin/python#-*- coding:utf8 -*-#简单的文件异常try: file("Jack.txt", "w+") print "write file"except IOError: print "the file can't be written"except: print "except"原创 2014-09-27 10:32:23 · 522 阅读 · 0 评论 -
python 界面库的简单使用
#!/usr/bin/python#-*- coding:utf8 -*-from Tkinter import *class Window: def __init__(self, root): frame = Frame(root) frame.pack() #进行调整 self.okBtn = Button原创 2014-09-28 11:28:02 · 3605 阅读 · 0 评论 -
wxPython中单元格示例
主要是一些资料的汇总:#!/usr/bin/python#-*- coding:utf8 -*-import wximport wx.grid as gridclass EventTable(grid.PyGridTableBase): def __init__(self): grid.PyGridTableBase.__init__(s原创 2014-10-06 21:25:40 · 2998 阅读 · 0 评论 -
wxPython的使用1
#!/usr/bin/python#-*- coding:utf8 -*-#C/C++程序员一般都喜欢用wxPython, QtPython等作为python的界面#现在主要讲讲wxPython吧import wx #导入界面库class Window(wx.Frame): #窗体的自定义 def __init__(self, root):原创 2014-09-29 16:45:49 · 896 阅读 · 0 评论 -
wxPython中list的简单使用
#!/usr/bin/python#-*- coding:utf8 -*-import wximport sysimport wx.lib.mixins.listctrl as listmixvalue = { 1:('1', 'staticText', u"静态文本框控件"), 2:('2', 'button', u"按钮控件"), 3:原创 2014-10-08 21:40:18 · 848 阅读 · 0 评论 -
wxPython中Button的使用方法
#!/usr/bin/python#-*- coding:utf8 -*-#主要讲讲button的使用import wxclass ButtonFrame(wx.Frame): def __init__(self, root): wx.Frame.__init__(self, None, -1, u"按钮", size=(300, 100))原创 2014-09-30 11:44:48 · 10232 阅读 · 0 评论 -
xwPython中Radio和CheckButton的使用
#!/usr/bin/python#-*- coding:utf8 -*-#这是一个多选框的设定import wxclass CheckBox(wx.Frame): def __init__(self, root): wx.Frame.__init__(self,None, -1, u"多选框",size=(200, 180))原创 2014-10-01 00:26:56 · 999 阅读 · 0 评论 -
wxython中List,ComboBox的使用
#!/usr/bin/python#-*- coding:utf8 -*-#现在简单讲下List的使用import wxclass ListFrame(wx.Frame): def __init__(self, root): wx.Frame.__init__(self, root, -1, u"下拉列表使用",size=(400, 300)原创 2014-10-01 09:58:28 · 2172 阅读 · 0 评论 -
wxPython中tree控件的简单使用
树形控件的简单使用#!/usr/bin/python#-*- coding:utf8 -*-import wxclass TreeFrame(wx.Frame): def __init__(self, root): values = [ '1', ['2', ['2-1', '2-2', ['2原创 2014-10-11 11:03:46 · 2257 阅读 · 0 评论 -
python解析xml
这里主要讲的是一个利用python解析xml和原创 2014-10-12 12:28:41 · 582 阅读 · 0 评论 -
定时器的使用
#!/usr/bin/python#-*- coding:utf8 -*-import wximport timeclass MyFrame(wx.Frame): def __init__(self, root): wx.Frame.__init__(self, root, -1, u"定时器示例", size=(400,400))原创 2014-10-11 14:39:47 · 613 阅读 · 0 评论 -
wxPython中的布局
#!/usr/bin/python#-*- coding:utf8 -*-#看看布局管理import wxclass GridFrame(wx.Frame): def __init__(self, root): wx.Frame.__init__(self, root, -1, u"布局管理-01",size=(300,200))原创 2014-10-02 13:51:33 · 720 阅读 · 0 评论 -
wxPython中的菜单
#!/usr/bin/python#-*- coding:utf8 -*-import wx#一个简单的菜单示例class MenuFrame1(wx.Frame): def __init__(self,root): wx.Frame.__init__(self, root, -1, u"菜单", size=(300,200)) p原创 2014-10-03 19:16:10 · 1189 阅读 · 0 评论 -
wxPython中Icon, MDI, HtmlWindow使用示例
#!/usr/bin/python#-*- coding:utf8 -*-import wximport wx.html as htmlclass IconFrame(wx.Frame): def __init__(self, root): wx.Frame.__init__(self, root, -1, u"Icon示例", size=(30原创 2014-10-04 10:47:00 · 1402 阅读 · 0 评论 -
dictionary的使用
#!/usr/bin/python#-*- coding:utf8 -*-import copytest_dict = {"Jack":22, "John":21, "Helen":20, "Smith":34}#打印所有的字典print test_dictprint test_dict["Jack"]test_dict1 = {1:"One", 2:"原创 2014-09-15 19:33:29 · 531 阅读 · 0 评论 -
字符串操作大全
#!/usr/bin/python#-*- coding:utf8 -*-#本章主要讲下字符串的操作#首先介绍字符串的格式化str1 = "Jack"str2 = "WJin"print "%s "% str1print "%s ^_^ %s" % (str1, str2)print "关于小数: %f--%.1f--%.2f" % (1.35, 1.35,原创 2014-09-17 10:15:24 · 514 阅读 · 0 评论 -
module的简单使用
module.py#!/usr/bin/python#-*- coding:utf8 -*-#首先在此处定义函数 在别的.py文件中调用def addFunc(x,y): return x+ydef delFunc(x,y): return x-ydef mulFUnc(x,y): return x*ydef divF原创 2014-09-16 20:46:37 · 610 阅读 · 0 评论 -
Python 获取sina首页所有jpg图片
#!/usr/bin/python#encoding:utf8import re #导入正则库 import urllib def getHtmlSource( url ): #获取网页源代码 pageHandle = urllib.urlopen( url ) htmlSource = pageHandle.read()原创 2014-09-06 22:00:41 · 717 阅读 · 0 评论 -
Pyhton 常用模块
python除了关键字(keywords)和内置的类型和函数(builtins),更多的功能是通过libraries(即modules)来提供的。 常用的libraries(modules)如下: 1)python运行时服务 * copy: copy模块提供了对复合(compound)对象(list,tuple,dict,custom class)进行浅拷贝和深拷贝的功能。翻译 2014-09-06 22:16:01 · 488 阅读 · 0 评论 -
Python模拟栈 和 队列
模拟Queue #!/usr/bin/pythonimport sysqueue = []def enQueue( data ): queue.append( data )def deQueue(): if len(queue) == 0: print "No data in the queue!" else:原创 2014-09-06 22:14:32 · 762 阅读 · 0 评论 -
文件的读写操作
#!/usr/bin/python#-*- coding:utf8 -*-#这一章主要介绍文件以及操作import os#创建文件 并写入数据write_context = """ This is a test from jack"""f = file("jack.txt", "w")f.write(write_context)f.cl原创 2014-09-20 19:06:27 · 582 阅读 · 0 评论 -
文件的一些基础操作(创建,复制,拷贝,查找)
#!/usr/bin/python#-*- coding:utf8 -*-import osimport re#进行文件的删除file("jack.txt", "w+")#可以看见当前文件夹下有意个jack.txt文件#进行文件的删除if os.path.exists("jack.txt"): os.remove("jack.txt")#没有j原创 2014-09-21 10:51:46 · 691 阅读 · 0 评论 -
配置文件以及目录遍历
#/usr/bin/python#-*- coding:utf8 -*-import difflibimport osf1 = open("test1.txt", "r")f2 = open("test2.txt", "r")src = f1.read()dst = f2.read()print srcprint dstf1.close(原创 2014-09-22 13:44:45 · 847 阅读 · 0 评论 -
简单的输出 python01
#!/usr/bin/python#-*- code:UTF-8 -*-if __name__ == "__main__": print "Hello world" print 1+2 name = "jack" print "%s is his name" % name firstname = name lastname =原创 2014-09-11 18:49:25 · 551 阅读 · 0 评论 -
输入输出 字节,字符流
#!/usr/bin/python#-*- coding:utf8 -*-import syssys.stdout = open("Jack.txt", "w+")print "Hello"sys.stdout.close()#创建文件并斜写入数据#sys.stdin = open("test1.txt", "r")#for line in sy原创 2014-09-22 21:27:15 · 593 阅读 · 0 评论 -
python类的介绍1
#!/usr/bin/python#-*- coding:utf8 -*-class Student: name = "" sex = "F" def __init__(self): self.name = "Hello" #默认的是Hello def setName(self, name): self.原创 2014-09-22 23:11:35 · 487 阅读 · 0 评论 -
总体简单介绍下python使用 python02
#!/usr/bin/python#-*- coding=UTF-8 -*-import sysimport random#随机数的产生num1 = random.randrange(1, 100, 2)print num1#现在随机产生100个随机数arr = []total = 0for i in range(100): num =原创 2014-09-13 11:43:09 · 545 阅读 · 0 评论 -
python类的使用2
#!/usr/bin/python#-*- coding:utf8 -*-import gcclass Student: def __init__(self, name="", age=""): self._name = name self._age = age #print self._name d原创 2014-09-23 10:37:11 · 478 阅读 · 0 评论 -
tuple的使用
#!/usr/bin/python#-*- coding:utf8 -*-#现在讲讲tuple的使用test_tuple = ("Jack", "Smith", "John", "Helen")#打印最后一个print test_tuple[-1]#打印倒数第二个print test_tuple[-2]#最后一个3不包括print test_tu原创 2014-09-14 21:04:09 · 560 阅读 · 0 评论 -
if语句的简单使用
#!/usr/bin/python#-*- coding:utf8 -*-from __future__ import division#简单的讲解if的使用 elif switch的使用def cmp(a, b): if a > b: print "a is bigger than b" elif a == b:原创 2014-09-14 13:50:22 · 1225 阅读 · 0 评论 -
python类的使用3
#!/usr/bin/python#-*- coding:utf8 -*-#将将Init函数中弗雷的初始化class Student(object): def __init__(self, name): print "student name is: ",nameclass SmallStudent(Student): def __in原创 2014-09-24 12:57:45 · 553 阅读 · 0 评论 -
list的使用
#!/usr/bin/python#-*- coding:utf8 -*-#现在讲一下list的使用test_list = ["jack", "smith", "helen", "John"]#打印所有的数据print test_list#打印倒数第一个print test_list[-1]#打印倒数第二个print test_list[-2原创 2014-09-15 10:15:11 · 550 阅读 · 0 评论 -
wxPython关于对话框
#!/usr/bin/python#-*- coding:utf8 -*-#现在讲讲dialog的使用import wximport osclass DialogFrame(wx.Frame): def __init__(self, root): wx.Frame.__init__(self, root, -1, u"对话框",size=原创 2014-10-05 16:15:00 · 769 阅读 · 0 评论
分享