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

PythonÊý¾Ý½á¹¹Ö®——list

     PythonÖÐÓÐËÄÖÖÄÚ½¨µÄÊý¾Ý½á¹¹£ºList£¬Tuple£¬Dictionary£¬Set¡£±¾ÎÄÖ÷Òª½éÉÜList¡£
     ListÊÇÓÃÀ´´æ·ÅÒ»×é¶ÔÏóÐòÁС£¿ÉÒÔÏñlistÖÐÌí¼ÓÔªËØ¡¢É¾³ýÔªËØ£¬Í¬Ê±Ò²¿ÉÒÔÏñ·ÃÎÊÊý×éÒ»Ñù·ÃÎÊlist¡£ListÊǿɱäµÄÊý¾ÝÀàÐÍ¡£
    ÏÂÃæ£¬¸ø³öÒ»×élistµÄʹÓÃʵÀý£º
     shoplist = ['rice','apple','banana','mango']
print('I hava ',len(shoplist),' items to purchase')
print('These items are:',end=' ')
for item in shoplist:
print(item,end=' ')
print('\nI also have to buy carrot')
shoplist.append('carrot')
print('My shoplist now is: ',shoplist)
shoplist.sort()
print('My shoplist after sorted is: ',shoplist)
del shoplist[1]
print('My shoplist after del is: ',shoplist)
shoplist.reverse()
print('My shoplist after reversed is: ',shoplist)
shoplist.remove('rice')
print('My shoplist after remove is: ',shoplist)

     Ê×ÏÈ£¬¿ÉÒÔʹÓÓ[]”À´´´½¨Ò»¸ölist£¬²¢¿ÉÒÔÖ±½Ó¶ÔÆä½øÐгõʼ»¯£»¿ÉÒÔʹÓÃfor..inÓï·¨À´µü´ú·ÃÎÊlist£»¿ÉÒÔʹÓÃappend·½·¨À´ÏòlistÖÐÌí¼ÓÔªËØ£»¿ÉÒÔʹÓÃremove·½·¨´ÓlistÖÐÒÆ³ýÔªËØ£»¿ÉÒÔʹÓÃdelÀ´´ÓlistÖÐɾ³ýÖ¸¶¨Ë÷ÒýµÄÔªËØ£»¿ÉÒÔʹÓÃsort·½·¨À´¶Ôlist½øÐÐÕýÐòµÄÅÅÐò£¬ÔÚÕâÀÐèҪעÒâµÄÊǸ÷½·¨²»·µ»ØÖµ£¬¶øÊÇÖ±½Ó¸Ä±älist±¾Éí£»¿ÉÒÔʹÓÃreverse·½·¨À´µ¹ÖÃlistÖеÄÔªËØ¡£
     ¹ØÓÚlistµÄ½øÒ»²½Ê¹Ó㬿ÉÒÔʹÓÃhelp(list)À´²é¿´¡£


Ïà¹ØÎĵµ£º

PythonÖ®HTMLParser

"""A parser for HTML and XHTML."""
# This file is based on sgmllib.py, but the API is slightly different.
# XXX There should be a way to distinguish between PCDATA (parsed
# character data -- the normal case), RCDATA (replaceable character
# data -- only char and entity references and end tags a ......

PythonÎļþ²Ù×÷ ´ò¿ª,¶ÁÈ¡,¹Ø±Õ

http://blog.alexa-pro.cn/?p=197
1.´ò¿ªÎļþ´úÂëÈçÏ£º
>>> f = open(”d:test.txt”, “w”)
˵Ã÷£ºµÚÒ»¸ö²ÎÊýÊÇÎļþÃû³Æ£¬°üÀ¨Â·¾¶£»µÚ¶þ¸ö²ÎÊýÊÇ´ò¿ªµÄģʽmode’r'£ºÖ»¶Á£¨È±Ê¡¡£Èç¹ûÎļþ²»´æÔÚ£¬ÔòÅ׳ö´íÎ󣩒w'£ºÖ»Ð´£¨Èç¹ûÎļþ ²»´æÔÚ£¬Ôò×Ô¶¯´´½¨Îļþ£©’a'£º¸½¼ ......

python udp c/s ¼Ç¼

server:
import sys
import socket
host = sys.argv[1]
port = int(sys.argv[2])
 
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
 
s.bind((host,port))
 
while 1:
    try:
   &n ......

python hidden features

from http://stackoverflow.com/questions/101268/hidden-features-of-python
http://www.okpython.com/bbs/thread-3434-1-1.html
http://www.okpython.com/bbs/thread-3436-1-2.html
http://www.okpython.com/bbs/thread-3437-1-2.html
http://www.okpython.com/bbs/thread-3438-1-1.html
http://www.okpython.com/bb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ