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

涉水The Python Challenge

在Stack Overflow 上看到学习Python 的一个方法是用Python 破解The Python Challenge。但我喜欢用Ruby,谁管得着呢^_^
0. 入门关很简单。
p 2**38 
1. 破解一段话,观察图片很容易发现解码表把字母表循环右移两位。
riddle = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
riddle.scan(/./).each do |char|
if /[a-z]/ =~ char
print (?a + (char[0] - ?a + 2) % 26).chr
else
print char
end
end 
译文:i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url.
再对url ("map")实施变换得"ocr"。
update: 发现String有个内置替换函数tr()。看,多简洁。
class String
def rot2
self.tr("a-xyz","c-zab")
end
end
p riddle.rot2 
2. 查看网页源码,可以看到网页注释中有一堆乱码,上面有句话"find rare characters in the mess below:"(“找出稀少的字符”)。想到用hash 来统计各个字符的出现次数,并记录首次出现的顺序。
riddle = '...' # the mess here
count = Hash.new(0)
seq = []
riddle.scan(/./).each do |char|
seq << char if count[char] == 0
count[char] += 1
end
p count, seq 
你会得到"equality"。第三关,我来了!


相关文档:

Python学习笔记 文件读写

Python中文件操作可以通过open函数,这的确很像C语言中的fopen。通过open函数获取一个file object,然后调用read(),write()等方法对文件进行读写操作。
1.open
使用open打开文件后一定要记得调用文件对象的close()方法。比如可以用try/finally语句来确保最后能关闭文件。
file_object = open('thefile.txt') ......

使用eclipse开发Python。

Help-》Software Upates-》Find and Install-》Search for new features to install-》New remote site-》随便起个name如pydev,url填 http://pydev.sf.net/updates/ -》然后照着提示下载安装即可。
Pydev的配置
在Eclipse IDE 下, 打开 Window->Preferences... 对话框,从右侧的树形列表中选择“ PyDev&r ......

关于Python中一种回调方式的实现

#关于回调功能的测试
#Functor是这种回调功能的关键对象
class Functor:
    """Simple functor class."""
    def __init__( self, fn, *args ):
        self.fn = fn
        ......

转段Python代码

#==================================================
import wx
import wx.media

class MyFrame(wx.Frame):
def __init__(self,parent,title):
wx.Frame.__init__(self,parent,-1,title,pos=(150,150),size&;nbsp;=(640, 480),style=wx.MAXIMIZE_BOX|wx.SYSTEM_MENU|wx.CAPTION|wx.CLOSE_BOX| ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号