一个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>