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

Python±à³ÌÎÊÌ⣬¿ÒÇë¸ßÊÖ½â»ó

×î½üÃÔÉÏÁËPython£¬ÔÚ˼¿¼ÔõÑùÓÃPythonд¸ö³ÌÐòʵÏÖ¶ÔÖ¸¶¨ÍøÂç¶Ë¿ÚµÄÊý¾Ý°üµÄץȡºÍ½âÎö£¬¿ÒÇë¸ßÊÖÖ¸½Ì£¡£¡

ÄãºÃ£¡
Ê×ÏÈ£¬ÊµÏÖ²¶°üµÄ¹¦ÄÜÐèҪʹÓÃwincap£¨windowsÏ£©£¬»òÕßlibpcap£¨LinuxÏ£©¡£
¶øPythonÌṩÁ˼¸¸ölibpcap bind£¬²»È磺http://monkey.org/~dugsong/pypcap/£¬ÕâÀïÓÐÒ»¸ö×î¼òµ¥µÄ¡£
ÔÚwindowsƽ̨ÉÏ,ÄãÐèÒªÏÈ°²×°winpcap¡£

ÏÂÃæÊÇÒ»¸ö¹æ·¶µÄ×¥°ü¹ý³ÌÀý×Ó£º

import pcap
import dpkt
pc=pcap.pcap() #×¢£¬²ÎÊý¿ÉΪÍø¿¨Ãû£¬Èçeth0
pc.setfilter('tcp port 80') #ÉèÖüàÌý¹ýÂËÆ÷
for ptime,pdata in pc: #ptimeΪÊÕµ½Ê±¼ä£¬pdataΪÊÕµ½Êý¾Ý
  print ptime,pdata #...

¶Ô×¥µ½µÄÒÔÌ«ÍøV2Êý¾Ý°ü(raw packet)½øÐнâ°ü

p=dpkt.ethernet.Ethernet(pdata)
if p.data.__class__.__name__=='IP':
  ip='%d.%d.%d.%d'%tuple(map(ord,list(p.data.dst)))
  if p.data.data.__class__.__name__=='TCP':
  if data.dport==80:
  print p.data.data.data # by gashero

һЩÏÔʾ²ÎÊý

nrecv,ndrop,nifdrop=pc.stats()
·µ»ØµÄÔª×éÖУ¬µÚÒ»¸ö²ÎÊýΪ½ÓÊÕµ½µÄÊý¾Ý°ü£¬(by gashero)µÚ¶þ¸ö²ÎÊýΪ±»ºËÐĶªÆúµÄÊý¾Ý°ü¡£
good luck£¡


¸ÐлÈý¥ǰ±²µÄ°ïÖú£¬´ýÎÒÏû»¯Ò»Ï°¡£¬Èç¹ûÓв»Ã÷°×µÄµØ·½£¬Ï£ÍûÄÜÔٵõ½ÄãµÄÖ¸µ¼£¡¸Ðл£¡

½¨ÒéLZ¿´PythonÍøÂç±à³Ì»ù´¡

´óÏÀÓÐÖÐÎÄ°æµÄ²»£¿
ÒýÓÃ
½¨ÒéLZ¿´PythonÍøÂç±à³Ì»ù´¡


Èç¹ûÏë¸úÉÏʱ´úµÄ·¢Õ¹£¬ ¾Í¶ÈÓ¢ÎÄ°æµÄ°Ñ£¬ Â¥ÉÏΪÄãÍƼöµÄºÜºÃ¡£


Ïà¹ØÎÊ´ð£º

python PILÄ£¿é´ò¿ªÍ¼Æ¬ÎÊÌâ

ÇëÎÊÏ£¬ÎÒµÄÊÇpython2.5°²×°ÁËPILÄ£¿é£¬È»ºó±àд³ÌÐò´ò¿ª±¾»úÉϵÄÒ»¸öͼƬʱ£¬ÎªÊ²Ã´ÀϳöÏÖ´íÎóÄØ£¬ÀÏÊÇÕÒ²»µ½Í¼Æ¬£¬´íÎóÌáʾÈçÏ£ºFile "C:\Python25\Lib\site-packages\PIL\Image.py", line 1888, in o ......

python ͼÏñ¶à±ßÐÎÇиî

pythonµÄPIL¿â×Ô´øµÄ·½·¨Ö»ÄܽøÐоØÐεÄÇиÈç¹ûÎÒÓÐÁËÒ»¸ö¶à±ßÐθ÷¸ö¶¥µãµÄ×ø±ê£¬ÈçºÎ¶ÔÏÖÓеÄͼƬ°´ÕÕÕâ¸ö¶à±ßÐνøÐÐÇиîÄØ£¿
²»Ò»¶¨ÒªÓÃPIL¿â£¬ÈκÎÄÜʵÏÖÕâ¸ö¹¦Äܵķ½·¨¶¼ÐС£

ͼƬÇиîµÄjs²»ÊǺܶàÂð£¿
......

¶®pythonµÄjava¸ßÊÖÇë½Ì - Java / Java SE

ÇëÎʸßÊÖ£¬pythonÀïµÄpopenÀàËÆjavaÀïµÄÄĸöÀà»òÕß·½·¨ÄØ£¿£¿ÁíÍâjython¿ª·¢java¸ÃÈçºÎʹÓÃjythonÄØ£¿£¿
1.¿ÉÄܺÍjavaÀïµÄRuntime.getRuntime().exec£¨"ϵͳÃüÁî"£©; Æô¶¯½ø³Ì
2.eclipseÏÂÔØjython ²å¼ ......

python½âÎöxmlÎļþ

ʹÓÃxml.dom½âÎö¼¸Õ×µÄxmlÎļþ£¬·Ç³£»ºÂý£¬ÓÐÖÖ¼ÙËÀµÄ¸Ð¾õ¡£Ôõô½â¾ö£¿ÓÃÆäËû¿âÊÇ·ñ»áºÃЩ£¬ÔÝʱֻ֪µÀÕâ¸ö¿âµÄ¡£
Äã¿ÉÒÔÊÔÒ»ÏÂElementTree


pythonµÄ¹Ù·½Àý×Ó
import xml.parsers.expat

# 3 handler ......

PYTHON Ò»¸ö³ÌÐò£¬23ÐÐÓÐ´í£¬²»Ã÷°×Ϊʲô ¾´ÇëÖ¸½Ì£¡

Python code:

class Rectangle:
def __init__(self, width, height):
self.width = width
self.height = height
def paint(self, factory):
point = factory.getPoint()
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ