Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

PythonͨѶ²¾

ÕâÁ½ÌìÔÚѧϰpythonÓïÑÔ£¬Ò²Ñ§×ÅдÁ˸öͨѶ²¾£¬Á·Ï°ÈëÃÅÏ£¡
¹¦ÄܰüÀ¨ÒÔÏ£º
1¡¢Ôö¼ÓÒ»Ìõ¼Ç¼
2¡¢É¾³ýÒ»Ìõ¼Ç¼
3¡¢ÐÞ¸ÄÒ»Ìõ¼Ç¼
4¡¢²éѯһÌõ¼Ç¼
5¡¢ÏÔʾÕû¸öͨѶ²¾
6¡¢°ïÖúÌáʾ
7¡¢°æ±¾ÏÔʾ
8¡¢Í˳öµÈ
Ê×ÏȽ¨Á¢Ò»¸öPersonÀ࣬¼´Person.pyÎļþ£¬ÓÃÀ´±£´æÁªÏµÈ˼Ǽ£º
class Person:
def __init__(self, name, email, phone):
self.name = name
self.email = email
self.phone = phone

½ÓÏÂÀ´ÊǸöaddressBook.pyÎļþ£¬ÓÃÒÔʵÏÖÉÏÃæÌáµ½µÄ¹¦ÄÜ£¬ÕâÀïÓÃÁË´æ´¢Æ÷£¬½«¶ÔÏó±£´æÔÚÎļþÖÐÀ´ÊµÏÖÊý¾Ý´æ´¢¡£
import cPickle as p
from Person import Person
filename = 'addressBook.data'
while True:
order = raw_input('/////////////////////////////////////\nEnter your order:')
#add
if order == 'add':
addName = raw_input('Enter name:')
f = file(filename)
dic = p.load(f)
if dic.has_key(addName) == False:
dic[addName] = Person(addName, raw_input('Enter email:'), raw_input('Enter phone:'))
f = file(filename, 'w')
p.dump(dic, f)
f.close()
#delete
elif order == 'del':
delName = raw_input('Enter name who you will delete:')
f = file(filename)
dic = p.load(f)
if dic.has_key(delName):
del dic[delName]
f = file(filename, 'w')
p.dump(dic, f)
f.close()
#modify
elif order == 'mod':
modName = raw_input('Enter name who you will modify:')
f = file(filename)
dic = p.load(f)
if dic.has_key(modName):
dic[modName] = Person(modName, raw_input('Enter email:'), raw_input('Enter phone:'))
f = file(filename, 'w')
p.dump(dic, f)
f.close()
#search
elif order == 'search':
schName = raw_input('Enter name who you will search:')
f = file(filename)
dic = p.load(f)
if dic.has_key(schName):
psch = dic[schName]
print psch.name
print psch.email


Ïà¹ØÎĵµ£º

python ¶ÁxmlÎļþ

def getText(self,nodelist):
rc=""
for node in nodelist:
if node.nodeType == node.TEXT_NODE or node.nodeType == node.CDATA_SECTION_NODE:
rc = rc + node.data
return rc
def parseXML(self,requesturl,xml):
dom = minidom.parse(requesturl)
for node in dom.getElementsByTagName('ca ......

Èà easy_install ʹÓôúÀí·­Ç½°²×° Python Ä£¿é

ÀµÓºƣ¨http://laiyonghao.com£©
¹Ø¼ü×Ö£ºpython, easy_install, setuptools, myentunnel, polipo, windows, linux, socks5, http, proxy
ÒòΪһЩÖÚËùÖÜÖªµÄÔ­Òò£¬ÎÒÃÇÓÐÐ©ÍøÕ¾ÎÞ·¨·ÃÎÊ£¬Ôì³ÉÉú»îºÍÉú²úµÄ¾Þ´ó²»±ã¡£ÆäÖжÔÎÒÓ°Ïì±È½Ï´óµÄÒ»¸ö¾ÍÊǰ²×°Ä³Ð© Python Ä£¿éµÄʱºò£¬easy_install ÎÞ·¨·ÃÎʵ½ÍøÕ¾¡£ÔÚÕâÀï·ÖÏíÈ ......

python ¶ÁhttpС¼Ç

conn = httplib.HTTPConnection(EPG_IP + ":" + HTTP_PORT)
url = FAV_URL_PARTH +"userid=" + USER_ID + FAV_DIR_MODIFY
param = '''<ps100request id="Favorite.Category.modify">
<categoryid>'''+categoryid+'''</categoryid>
<categoryname>'''+categoryname+'''</ ......

PythonÖ®ÃÀ DecoratorÉîÈëÏê½â(Ò»)

There should be one—--and preferably only one –--obvious way to do it.
                                     ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ