上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 38 下一页
摘要: #coding:utf-8from Tkinter import *class App: def __init__(self,root): #定义帧 frame = Frame(root) frame.pack() self.frame = frame w = Label(frame,text = ... 阅读全文
posted @ 2013-06-30 17:17 前行者2011 阅读(133) 评论(0) 推荐(0) 编辑
摘要: from Tkinter import *class App: def __init__(self,root): frame = Frame(root) frame.pack() self.frame = frame w = Label(frame,text = "calculator") w.pa... 阅读全文
posted @ 2013-06-30 17:11 前行者2011 阅读(117) 评论(0) 推荐(0) 编辑
摘要: import timeimport Tkinter as tkclass App: def __init__(self): self.root = tk.Tk() self.label = tk.Label(text="") self.label.pack() self.update_clock()... 阅读全文
posted @ 2013-06-30 17:08 前行者2011 阅读(259) 评论(0) 推荐(0) 编辑
摘要: #使用递归,输出所有的列表元素l1 = [1,2,3,[4,5,6],[4,3,2,1,['a','b','c'],[ ] ] ]def getElement(l): for i in l: if isinstance(i,list): getElement(i) else: print i,get... 阅读全文
posted @ 2013-06-30 11:54 前行者2011 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 父目录中的模块调用子目录中的模块:---------------------------------------------------------目录 dir下存在以下目录:a.py文件、subdir子目录。 subdir子目录下有b.py在dir的a中调用子目录下的b.py文件:1.在subdi... 阅读全文
posted @ 2013-06-30 11:22 前行者2011 阅读(74) 评论(0) 推荐(0) 编辑
摘要: l = ['a','b']def my_list(a): '''#重新定义一个新的列表l,是局部变量,与上面的l不一样。 使用global l可以定义全局变量l,此时可以对上面的l进行操作''' l = [] # 局部变量 l.append(a)my_list(1)my_list('2')print... 阅读全文
posted @ 2013-06-30 09:54 前行者2011 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 从网页中抓到的字符串s = ''用Python可以这样处理: import HTMLParserhtml_parser = HTMLParser.HTMLParser()s = html_parser.unescape(s) #这样就得到了s = '' 阅读全文
posted @ 2013-06-28 19:00 前行者2011 阅读(90) 评论(0) 推荐(0) 编辑
摘要: Python 中的bisect用于操作排序的数组,比如你可以在向一个数组插入数据的同时进行排序。下面的代码演示了如何进行操作:bisect.bisect( l , r) 假设列表l已排序,返回元素r可以插入在列表l的索引位置bisect.insort(l,i) 假设l是有序的列表,插入i,并保持最新... 阅读全文
posted @ 2013-06-28 17:58 前行者2011 阅读(133) 评论(0) 推荐(0) 编辑
摘要: '''有三个门,只有一个门后有驴,让嘉宾先猜一个门,然后主持人提出去掉一个没驴的门,然后让用户选择是否再更换选择'''import randomdoor =['A','B','C']dunkey = random.choice(door)print "驴在:",dunkeywhile 1: user... 阅读全文
posted @ 2013-06-28 10:37 前行者2011 阅读(115) 评论(0) 推荐(0) 编辑
摘要: python getopt的使用 getopt.getopt(args, options[, long_options]) #options 中不包含-或--import getopts='ping -c 12 -t 1.0 -6 -s 1024 192.168.0.1'sys.argv=s.spl... 阅读全文
posted @ 2013-06-26 18:02 前行者2011 阅读(93) 评论(0) 推荐(0) 编辑
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 38 下一页