随笔分类 - Python
py2exe 转换 pytetris
摘要:首先,需要一个给 py2exe 使用的 python 脚本,我命名为 setup.py,内容如下:1fromdistutils.coreimportsetup2importglob,shutil3importpy2exe4setup(windows=["main.py"])5shutil.copytree('SFX','dist/SFX')6shutil.copytree('Image','dis...
阅读全文
python 读取 windows event log 的简短代码
摘要:最近要把远程机器上的事件日志拿回本地分析,不过不管是直接在事件查看器另存还是用dumpel.exe备份,都不是很合自己心意。我一时又没找到更好的工具,不过手里有python啊。下面是简单的源代码,仅满足自已目前的需要 1 # -*- coding: cp936 -*- 2 def Usage(): 3 print '-f windows event log .evt格式备份' 4 ...
阅读全文
IronPython 1.0 Release Candidate (转贴 ( 据说比c实现的快1.5!) )
摘要:IronPython 1.0 Release Candidate One of the great features of the .NET framework is the Common Language Infrastructure (CLI). The CLI provides a common foundation for a wide variety of programming l...
阅读全文
BtTorrent 的 bencoding
摘要:bencoding是BT用来说明与组织数据的格式。BitTorrent-4.1.6\BitTorrent\bencode.py是算法的实现。bencoding相当简单,不过我还是写了一个UnitTest来验证我的理解。 1 import unittest 2 from BitTorrent.bencode import * 3 4 class testBencodeFun(unitte...
阅读全文
用python快速开发一个实用的socket服务器
摘要:首先,要明白不是所有的socket服务都需要高性能。如果要求高性能,使用IOCP或EPoll模式用C/C++来完成,直接用API写,用ACE的proactor封装来完成是比较恰当的行为。但当性能不是主要问题时,用Python来写socket服务,并享受高的开发效率将是一件快乐的事。下面,是用python完成的一个每thread/connect的一个echo服务。 经常的,在写一...
阅读全文
TinyP2P 世界最小的P2P应用
摘要:# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html) import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, E.W. Felten ar,pw,res = (sys.argv,lambda u:hmac.new(sy...
阅读全文
python小代码:ElapsedTime
摘要:我在一个项目中用python做业务逻辑部分的代码,但速度不够理想,记录业务逻辑各段代码的用时情况并分析瓶颈就成了必须的工作。于是动手写了下面的ElapsedTime.PY,帮助解决问题。 import sysimport timeclass ElapsedTime: def __init__(self, scope = ""): self.scope_name ...
阅读全文
浙公网安备 33010602011771号