易截截图软件、单文件、免安装、纯绿色、仅160KB

基本数据结构的python实现 队列

队列:
与堆栈类似,通过python的列表类型来实现,参考 help(list)
shoplist=['apple','mango','carrot','banana']
print 'I have',len(shoplist),'items to purchase'
print 'these items are:'
for item in shoplist:
print item,
shoplist.append('rice')
print 'my shopping list is now', shoplist
shoplist.sort()
print 'Sorted shopping list is',shoplist
olditem=shoplist[0]
del shoplist[0]
print 'I bought the',olditem
print 'My shopping list is now',shoplist


相关文档:

如何运行Python脚本

假设你你的操作系统是WinXP:

开始菜单-> 运行-> cmd

然后就可以敲命令了。

如果你用IDLE,可以用IDLE打开这个.py文件,然后在菜单 "Run "下有一项 "Run   Module ",点击即可。 ......

Python中reactor,factory,protocol的学习笔记


Python中reactor,factory,protocol的学习笔记
 
 
最为简单的情况下,除了了解清reactor的简单使用,你还要了解Protocol和Factory。它们最终都会由reactor的侦听建立和run来统一调度起来。    
   
     建立服务器的第一个要解决的问题就是服务与外界的交流协 ......

使用python获取html页面的内容

import urllib
from HTMLParser import HTMLParser
class TitleParser(HTMLParser):
def __init__(self):
self.title = ''
self.divcontent = ''
self.readingtitle = 0
self.readingdiv = 0
HTMLParser.__init__(self)
def handle_starttag(self, tag, attrs): ......

基本数据结构的python实现 堆栈

前言:
最近又想学习python,又想去温习一下算法,于是就想出了这个两不误的方法,^_^
堆栈:
使用python的列表结构,详情可以查看help(list)
#Filename: stack.py
shoplist=['apple','mango','carrot','banana']
shoplist.append('rice')
popitem=shoplist[-1]
del shoplist[-1]
print 'the popitem is',popitem
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号