您的位置:首页 > 编程语言 > Python开发

Python入门学习(三)GUI程序

2014-11-01 20:24 232 查看
一个GUI程序

# -*- coding: cp936 -*-
from Tkinter import *
# 创建定义GUI的应用程序类和事件处理方法
class KeysApp(Frame):
def __init__(self):
Frame.__init__(self)
self.txtBox = Text(self)
self.txtBox.bind('<space>',self.doQuitEvent )
self.txtBox.pack()
self.pack()
def doQuitEvent(self,event):
import sys
sys.exit()

myApp = KeysApp()
myApp.mainloop()


正则表达式

# .表示通配符
re.match('be.t','best')
# <_sre.SRE_Match object at 0x01E93720>

# []表示搜索符,将搜索方括号中的任何一个字符
re.match('s[pwl]am','spam')
# <_sre.SRE_Match object at 0x01E975D0>

# 通过放置一个^标志来作为组的第一个元素,可以查找到多列字符之外的任何字符
re.match('[^f]ool','cool')
# <_sre.SRE_Match object at 0x01E93720>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: