Section o off
Using Python to calculate 2 * * 38, replace the URL to
1th Pass
Really covered, and finally Google a bit, only to understand that all the letter displacement >> two-bit
Import= Str.maketrans ('abcdefghijklmnopqrstuvwxyz',' Cdefghijklmnopqrstuvwxyzab')print("'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. ". Translate (trans))
Learning function:
Maketrans (str1, str2) make a conversion table that converts the letter one by one in str1 to the letter in the str2 corresponding position
Translate (trans) converting strings using conversion tables
2nd Pass
Look directly to the source file interface
The original is counting AH.
>>> fromUrllibImport*>>> fromUrllib.requestImport*>>> res = Urlopen ('http://www.pythonchallenge.com/pc/def/ocr.html')>>>ImportRe>>> template = Re.compile ('<!--. *?-->', Re. Dotall)>>> A =re.findall (template, Res.read (). Decode ())>>> fromCollectionsImportCounter>>> Counter (a[1]) Counter ({')': 6186,'@': 6157,'(': 6154,']': 6152,'#': 6115,'_': 6112,'[': 6108,'}': 6105,'%': 6104,'!': 6080,'+': 6066,'$': 6046,'{': 6046,'&': 6043,'*': 6034,'^': 6030,'\ n': 1221,'-': 4,'a': 1,'T': 1,'I': 1,'L': 1,'<': 1,'y': 1,'>': 1,'u': 1,'e': 1,'Q': 1})
It's kind of interesting.
Because the HTML is too large, I open it directly with Urlopen () and then take the regular expression out of that part (of course, in order to show the superiority of the regular expression found a ' <!--. *?--> ' match pattern, will match two strings out, the second string is asked, can be compared to HTML), Next follow the hint to find the least number of things. Ignore the <!---->.
A, T, I, L, y, u, E, q
And then he was blindfolded. What is this xxoo? Put it directly in the URL and put it in 404 after sorting.
English residue. It turned out to be equality. (Baidu's)
Learning function:
Urlopen (URL): Receive a html/equivalent to open a file, the operation is almost consistent
Compile (pattern, flag): Compile a regular expression matching string, speed up the use of multiple times, flag is used to adjust the matching pattern, for example, we need to use Dotall. Match \ n to match.
Counter (obj): Can be a string, list,tuple, and so on, returning a dict that contains the number of occurrences of all elements.
Python Challenge 0~2