Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÖÐÒ»Öֻص÷·½Ê½µÄʵÏÖ

#¹ØÓڻص÷¹¦ÄܵIJâÊÔ
#FunctorÊÇÕâÖֻص÷¹¦ÄܵĹؼü¶ÔÏó
class Functor:
    """Simple functor class."""
    def __init__( self, fn, *args ):
        self.fn = fn
        ......

´ô´ôµÄPython ±Ê¼Ç


һЩ×ۺϵÄÐÅÏ¢
Python
ÀËõ½øºÜÖØÒª¡£Ã»ÓмâÀ¨ºÅ²»Òª½ô£¬

Python
¸ù¾ÝËõ½øÀ´·Ö¸îÓï¾ä¿é¡£
²ÎÊý²»ÐèÒª¶¨Ò壬¿ÉÒÔÖ±½ÓʹÓá£
Help(var)
²é¿´
var
µÄ°ïÖú¡£
Var
¿ÉÒÔΪÈκζ«Î÷£¬º¯Êý£¬Ä£¿é£¬Àà¡£
Python
ÖеÄ×Ö·û´®ÊDz»¿É±äµÄ¡£
Pass 
±íʾ¿ÕÓï¾ä¿é¡£
# ×¢ÊÍ
 
String
r‘I&rsquo ......

ʹÓà Django ºÍ Python ¿ª·¢ Web Õ¾µã


 
 
Ian Maurer (ian@itmaurer.com), ×ÊÉî¹ËÎÊ, Brulant, Inc.
2006 Äê 7 ÔÂ 03 ÈÕ
±¾ÏµÁÐÎÄÕÂÒ»¹²ÓÐÁ½Æª£¬±¾ÎÄÊÇÆäÖеĵÚһƪ¡£ÔÚÕâһƪÎÄÕÂÖУ¬ÎÒÃǽ«Õ¹Ê¾ Django µÄÓ÷¨£¬Django ÊÇ Python ±à³ÌÓïÑÔÇý¶¯µÄÒ»¸ö¿ªÔ´Ä£ÐÍ-ÊÓͼ-¿ØÖÆÆ÷£¨MVC£©·ç¸ñµÄ Web Ó¦ÓóÌÐò¿ò¼Ü¡£Ê¹Óà Django£¬ÎÒÃÇÔÚ¼¸·ÖÖÓÖ®ÄÚ¾ ......

ת¶Î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ºÅ