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

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:
        message, address = s.recvfrom(100)
        print "Got data from", address, message
 
        #cs = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        #cs.sendto(message, address)
        #cs.close()
 
        s.sendto(message, address)
 
    except (KeyboardInterrupt, SystemExit):
        raise
    except:
        traceback.print_exc()
client:
import socket
import sys
import time
count = 0
while (count < 9):
    try:
        time.sleep(1)
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.sendto("test", ("192.168.22.209", 1234))
        data,addr = s.recvfrom(1024)
        if data:
            print 'received:',data,'from',addr
        s.close()
    except:
        print 'except'


Ïà¹ØÎĵµ£º

Linux Ï CÓïÑÔ´óÎļþ¶Áд(´óÓÚ4G£©

ÒÔϵÄ×ö·¨ÕûÀí×ÔÂÛ̳ÉϵÄÌû×Ó¡£ 
ÈçºÎcreate´óÎļþ
Òª´ó¾Í·Ç³£´ó£¬1T°É¡£
ÓÐÁ½ÖÖ·½·¨£º
 
Ò».dd
dd if=/dev/zero of=1T.img bs=1G seek=1024 count=0
bs=1G±íʾÿһ´Î¶Áд1GÊý¾Ý£¬count=0±íʾ¶Áд0´Î£¬seek=1024±íʾÂÔ¹ý1024¸öBlock²»Ð´£¬Ç°Ãæblock sizeÊÇ1G£¬ËùÒÔ¹²ÂÔ¹ý1T£¡
ÕâÊÇ´´½¨´óÐÍsparseÎļþ×î¼ ......

ÔÚpythonÖд¦ÀíXML×ܽá

±¾ÎÄ×ܽáÁËÔÚPythonÖÐÖ÷ÒªµÄ¼¸ÖÖ´¦ÀíXMLµÄ·½·¨£º
Element Tree
SAX
Dom
ʹÓõÚÈý·½Àà¿âÈçAmara 2.x£¬ libxml2dom µÈ
Element Tree
Element TreeÊÇPython 2.5ÒýÈëµÄʹÓüòµ¥£¬¿ì½ÝµÄ´¦Àí·½·¨£¬ Ò²ÊÇPython±ê×¼Àà¿âÍƼöµÄ´¦ÀíXMLµÄ·½·¨¡£
ËüʹÓÃÊ÷ÐνڵãµÄÐÎʽÀ´¶ÁдXML¡£Element TreeÊÇÇáÁ¿¼¶µÄDOM£¬ ËùÒÔÊ ......

Eclipse»ùÓÚpython¡¢Django×öWeb¿ª·¢

 ÏȽ«ÉÏÃæ´´½¨ºÃµÄtestdemo¹¤³ÌĿ¼\£¬½«C:\Python25\Lib\site-packages\django\binÖеÄtestdemoĿ¼¿½±´µ½×Ô¼ºµÄ¹¤×÷Ŀ¼ÖУ¬È»ºóÆô¶¯eclipse£¬µã»÷“File”->“New”->“project…”£¬½«»á¿´µ½ÒÔÏ»­Ãæ
 
Ñ¡Ôñ“Pydev Project”£¬µã»÷“Next&rdquo ......

ZZ python´¦ÀíÖÐÎÄ


ÒÔÏÂΪÎÒÔÚ´¦ÀíÍøÒ³±àÂëÎÊÌâ¿´µÄÎÄÕ£¬ÏÖÔÚдÅÀ³æ×Ô¼º´¦ÀíÍøÒ³±àÂëÎÊÌâȷʵ±È½ÏÂé·³£¬ÍøҳҲûÓй涨
Ò»¶¨ÒªÔÚMETAÍ·ÐÅÏ¢Àï´ø±àÂëÐÅÏ¢£¬¶øºÜ¶àÈËдµÄ̽²â±àÂë¾ÍÊÇ»ñÈ¡META£¬ÕâÊDz»¿ÉÈ¡µÄ£¬¶øÓеÄÈËÔòÊÇ·ÖÎöHTTP·µ»ØµÄÊý¾Ý°üÀï±ßµÄ
charset£¬È磨a.headers.getparam('charset')£©£¬¶øHTTP°üûÓй涨һ¶¨Òª´øcharset£¬ËùÒ ......

ʹÓÃpdbµ÷ÊÔPython³ÌÐò

ʹÓÃpdbµ÷ÊÔPython³ÌÐò
 
±¾ÎÄÌÖÂÛÔÚûÓз½±ãµÄIDE¹¤¾ß¿ÉÓõÄÇé¿öÏ£¬Ê¹ÓÃpdbµ÷ÊÔpython³ÌÐò
 
Ô´ÂëÀý×Ó
ÀýÈ磬ÓÐÄ£ÄâË°ÊÕ¼ÆËãµÄ³ÌÐò£º
 
#!/usr/bin/python
def debug_demo(val):
                if val &l ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ