程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

[pythonchallenge]-- explanation of 5~6 levels

編輯:Python

Last article :[pythonchallenge]-- 0~4 Guan explanation

Hzy The blog of

The first 5 Turn off

This level is the same , We have to look at the web source code , You'll find one banner.p link , And then we open up , Found a bunch of symbols , We need to Deserialization

  • Here we use pickle To deserialize .
  • After serialization , You will find a two-dimensional list , Many items in the list ('', Numbers ), perhaps ('#', Numbers )
  • The number here refers to , The number of times symbols appear .
  • We print out all the characters , You can see the answer .

Code :

import requests
import pickle
text = requests.get("http://www.pythonchallenge.com/pc/def/banner.p").content
print(pickle.loads(text))
for list in pickle.loads(text):
print(''.join(l[0] * l[1] for l in list))
# http://www.pythonchallenge.com/pc/def/channel.html

You'll find one channel The characters of

The first 6 Turn off

There is only one zipper in this level , Similarly, we open the source code

The first line has a comment :<!-- <-- zip -->, Found in the whole source code , With one form, there is nothing else , Looked at half a day , Know how to fix it .

  • Finally, I found out that we had to html Switch to zip, Download a zip file
  • Open this file and we will find , It's all some txt The file of .
  • The document says :Next nothing is 91038, It is very similar to a previous level .
  • There's a readme.txt: Prompt us to start from 90052.txt Start , At the same time, the answer is in the compressed package
  • And then we start with 90052 Start traversing .
  • The result is 46145.txt, prints :Collect the comments.
  • Combined with the answer just prompted in the compressed package , The original answer is that the notes of each file are combined .
  • We print notes for all the documents , Get the results :hockey

Code

import re
first = "90052.txt"
while True:
with open("./channel/" + first, "r") as t:
text = t.readline()
answer = re.findall("\d+", text)
if len(answer) == 1:
first = answer[0] + ".txt"
print("path:{} and text:{}".format(first, text))
else:
print(first)
print(text)
break
# Collect the comments.
import zipfile
first = "90052.txt"
file = zipfile.ZipFile('./channel.zip', 'r')
print(file)
while True:
line = str(file.read("%s" % first))
m = re.search("\d+", line)
print(file.getinfo("%s" % first).comment.decode("utf-8"), end="")
if m is None:
print(file.getinfo("%s" % first).comment.decode("utf-8"))
break
first = m.group(0)+".txt"

Then open the connection :http://www.pythonchallenge.com/pc/def/hockey.html.

  • You will get the following sentence :it’s in the air. look at the letters.
  • … Letters in the air … The answer is oxygen :oxygen, I didn't know until I saw someone else's , I can't think of .

Tomorrow, I'll do some questions .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved