标签:
0.
1 print 2**38 2 ##apply the result to the url
1. 看图是要right shift两位, 切片即可。
1 import string 2 3 intab = string.ascii_lowercase 4 outtab = intab[2:] + intab[:2] 5 trans_table = string.maketrans(intab, outtab) 6 7 s = """ 8 g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle 9 gr gl zw fylb gq glcddgagclr ylb rfyr‘q ufw rfgq rcvr gq qm jmle. 10 sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.""" 11 12 print s.translate(trans_table) 13 print ‘map‘.translate(trans_table) 14 15 ##The result is 16 ## 17 ## i hope you didnt translate it by hand. thats what computers are for. doing 18 ## it in by hand is inefficient and that‘s why this text is so long. 19 ## using string.maketrans() is recommended. now apply on the url. 20 ##ocr 21 22 ##apply ocr to the url
2. 寻找出现次数少的character
1 import string 2 3 result = {} 4 text = open(‘003help.txt‘).read() 5 for ch in text: 6 result[ch] = result.get(ch, 0) + 1 7 8 print result 9 print ‘‘.join(ch for ch in result if result[ch]==1) 10 s = [] 11 for i in text: 12 if i in string.ascii_lowercase: 13 s.append(i) 14 print ‘‘.join(s) 15 16 ##apply ‘equality‘ to the url
3. One small letter, surrounded by EXACTLY three big bodyguards on each of its sides. 正则表达式!
import re pattern = re.compile(‘[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]‘) text = open(‘004help.txt‘).read() t = re.findall(pattern, text) print ‘‘.join(t) ##apply to the url
stay tuned...
标签:
原文地址:http://www.cnblogs.com/FARAMIR/p/4634809.html