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

Python Socket编程

1,编写Server.py
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
s.bind(('localhost',8081))
while True:
    data,addr=s.recvfrom(1024)
    print 'receive:',data,'from',addr
2,编写Client.py
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
while True:
    msg=raw_input()
    s.sendto(msg,('localhost',8081))
3,运行程序
不同cmd窗口,分别运行两个py。Client窗口输入信息,Server窗口输出相应信息。


相关文档:

Python之美 Decorator深入详解(一)

There should be one—--and preferably only one –--obvious way to do it.
                                     ......

windows & python & Emacs


设置Emacs的HOME,可以在scratch buffer中输入:(insert (getenv "HOME"))查看
下载python-mode.el
用Emacs打开python-mode.el然后M-x byte-compile-file编译python-mode.el为elc
C-h v查看load-path变量
在HOME/.emacs.d/init.el中添加(setq load-path (cons "D:\\emacs-23.1-bin-i386" load-path))
将py文件与pytho ......

Python 下载网页的几种方法

总结下,Python 下载网页的几种方法
1
 fd = urllib2.urlopen(url_link)
 data = fd.read()
 这是最简洁的一种,当然也是Get的方法
2
通过GET的方法
def GetHtmlSource(url):
    try:
   
        htmSource = ''
 &nb ......

Python 线程池的实现

import urllib2
import time
import socket
from datetime import datetime
from thread_pool import *

def main():
url_list = {"sina":"http://www.sina.com.cn",
"sohu":"http://www.sohu.com",
"yahoo":"http://www.yahoo.com",
"xiaonei":"http://www.x ......

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


Python中reactor,factory,protocol的学习笔记
 
 
最为简单的情况下,除了了解清reactor的简单使用,你还要了解Protocol和Factory。它们最终都会由reactor的侦听建立和run来统一调度起来。    
   
     建立服务器的第一个要解决的问题就是服务与外界的交流协 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号