python challenge
import string
######## 1 ###############else chr(ord(‘a’)+1-ord(‘z’)+ord(x))
s = “http://www.pythonchallenge.com/pc/def/map.html”
l1 = [chr(ord(x)+2)for x in s if ord(‘a’)<=ord(x) <=ord(‘z’)]
s2 = ‘’.join(l1)
l2 = [chr(ord(x)-26) if x ==’|’ or x == ‘{’ else x for x in s2 ]
s3 = ‘’.join(l2)
print(s3)
############### 4 #################
import requests
import re
ans = “12345”
# key = [‘44827’]
number = re.compile("\d+")
n = 1
while n<401:
r = requests.get(“http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=” + ans)
t = r.text
key = re.findall(number, str(t)) # 返回值为列表
if len(key) == 2:
print(t)
temp_text1 = requests.get(“http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=” + ‘’.join(key[1])).text
temp_num1 = re.findall(number, str(temp_text1))
if temp_num1:
ans = ‘’.join(temp_num1)
print(ans)
else:
temp_text2 = requests.get(“http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=” + ‘’.join(key[1])).text
temp_num2 = re.findall(number, str(temp_text2))
ans = ‘’.join(temp_num2)
print(ans)
elif key:
ans = ‘’.join(key)
print(ans)
else:
print(t)
ans = str(int(ans)/2)
# break
n = n+1
################## 5 ######################
import requests
import re
import pickle
# r = requests.get(“http://www.pythonchallenge.com/pc/def/banner.p”)
# t = r.text
original = “D:\Desktop\python学习\新建文本文档.txt”
destination = “D:\Desktop\python学习\新建文本文档2.txt”
content = ‘’
outsize = 0
with open(original, ‘rb’) as infile:
content = infile.read()
with open(destination, ‘wb’) as output:
for line in content.splitlines():
outsize += len(line) + 1
output.write(line + str.encode(’\n’))
# print(“Done. Saved %s bytes.” % (len(content)-outsize))
f2 = open(‘D:\Desktop\python学习\新建文本文档2.txt’,‘rb’)
l = pickle.load(f2) # 一个列表
print(l)
for t in l:
ans = ‘’
for i in t:
ans = ans + i[0]*i[1]
print(ans)
################### 6 #########################
import requests
import re
import os
import zipfile
ff = zipfile.ZipFile(‘D:\Downloads\channel.zip’)
f2 = open(‘D:\Desktop\python学习\新建文本文档.txt’,‘wb’)
# print(ff.getinfo(‘46145.txt’))
number = re.compile("\d+")
ans = ‘90052’
files = []
for root,dirs,file in os.walk(‘D:\Downloads\channel’):
files = file
w = []
while True:
f = open(‘D:\Downloads\channel\’ + ans + ‘.txt’)
text = f.read()
t = re.findall(number, text) # 返回值是列表
if t:
ans = ‘’.join(t)
# print(ans, text)
k = ff.getinfo(ans+’.txt’).comment
f2.write(k)
# w.append(k)
# print(k)
else:
# print(ans, text)
# w.append(k)
# print(k)
break
f2 = open(‘D:\Desktop\python学习\新建文本文档’,‘wb’)
f2.write(w)
print(w)
####################### 7 #####################
import urllib.request as ur
from PIL import Image
import requests
im_in = open(‘D:\Desktop\python学习\iamge.png’,‘wb’)
r = requests.get(“http://www.pythonchallenge.com/pc/def/oxygen.png”) # 个人觉得是字符串。不是字符串,是response
print(r.content)
im_in.write(r.content)
im_in.close()
im_out = Image.open(‘D:\Desktop\python学习\iamge.png’)
(width,height) = im_out.size
# print(width,height)
pixel1 = im_out.getpixel((0,height/2))
a = pixel1[0]
for i in range(1, width, 1):
pos = (i, height / 2)
# pixel(49,49,49,255)前三位代表的是rgb的值.
pixel = im_out.getpixel(pos)
# ascii码转字符
if pixel[0] == pixel[1] == pixel[2]:
if a != pixel[0]:
print(chr(pixel[0]),end=’’)
a = pixel[0]
else:
continue
print(’ ‘,end=’’)
else:
break
# char = chr(pixel[0])
print(’’.join(map(chr, [105, 110, 116, 101, 103, 114, 105, 116, 121])
################### 8 ####################################
import requests
import re
r = requests.get(“http://www.pythonchallenge.com/pc/def/integrity.html”)
content = r.text
content = re.sub(’\n’,’’,content)
content = re.findall(".*",content)
s = ‘’.join(content)
un = re.findall(“un: ‘([^’]*)”,s)
print(s)
s2 = ‘’.join(un)
print(s2)
######################## 9 #################################
import requests
from PIL import Image
first = [146,399,163,403,170,393,169,391,166,386,170,381,170,371,170,355,169,346,167,335,170,329,170,320,170,
310,171,301,173,290,178,289,182,287,188,286,190,286,192,291,194,296,195,305,194,307,191,312,190,316,
190,321,192,331,193,338,196,341,197,346,199,352,198,360,197,366,197,373,196,380,197,383,196,387,192,
389,191,392,190,396,189,400,194,401,201,402,208,403,213,402,216,401,219,397,219,393,216,390,215,385,
215,379,213,373,213,365,212,360,210,353,210,347,212,338,213,329,214,319,215,311,215,306,216,296,218,
290,221,283,225,282,233,284,238,287,243,290,250,291,255,294,261,293,265,291,271,291,273,289,278,287,
279,285,281,280,284,278,284,276,287,277,289,283,291,286,294,291,296,295,299,300,301,304,304,320,305,
327,306,332,307,341,306,349,303,354,301,364,301,371,297,375,292,384,291,386,302,393,324,391,333,387,
328,375,329,367,329,353,330,341,331,328,336,319,338,310,341,304,341,285,341,278,343,269,344,262,346,
259,346,251,349,259,349,264,349,273,349,280,349,288,349,295,349,298,354,293,356,286,354,279,352,268,
352,257,351,249,350,234,351,211,352,197,354,185,353,171,351,154,348,147,342,137,339,132,330,122,327,
120,314,116,304,117,293,118,284,118,281,122,275,128,265,129,257,131,244,133,239,134,228,136,221,137,
214,138,209,135,201,132,192,130,184,131,175,129,170,131,159,134,157,134,160,130,170,125,176,114,176,
102,173,103,172,108,171,111,163,115,156,116,149,117,142,116,136,115,129,115,124,115,120,115,115,117,
113,120,109,122,102,122,100,121,95,121,89,115,87,110,82,109,84,118,89,123,93,129,100,130,108,132,110,
133,110,136,107,138,105,140,95,138,86,141,79,149,77,155,81,162,90,165,97,167,99,171,109,171,107,161,
111,156,113,170,115,185,118,208,117,223,121,239,128,251,133,259,136,266,139,276,143,290,148,310,151,
332,155,348,156,353,153,366,149,379,147,394,146,399]
second = [156,141,165,135,169,131,176,130,187,134,191,140,191,146,186,150,179,155,175,157,168,157,163,157,159,
157,158,164,159,175,159,181,157,191,154,197,153,205,153,210,152,212,147,215,146,218,143,220,132,220,
125,217,119,209,116,196,115,185,114,172,114,167,112,161,109,165,107,170,99,171,97,167,89,164,81,162,
77,155,81,148,87,140,96,138,105,141,110,136,111,126,113,129,118,117,128,114,137,115,146,114,155,115,
158,121,157,128,156,134,157,136,156,136]
# second = []
dot = first + second
l = len(dot)
x = [dot[i] for i in range(0, l) if i % 2 == 0]
y = [dot[i] for i in range(0, l) if i % 2 != 0]
ll = len(x)
# r = requests.get(“http://www.pythonchallenge.com/pc/return/good.jpg”)
# content = r.content
# print(content)
# im = open(“D:\Desktop\python学习\image.jpg”, ‘wb’)
# im.write(content)
# im.close()
im = Image.open(“D:\Desktop\python学习\good.jpg”)
w,h = im.size
im2 = Image.new(im.mode,(w,h))
for i in range(0, ll):
# print(i)
im2.putpixel((x[i],y[i]), (255,255,255))
# for i in range(0,50):
# im.putpixel((i, i), (0, 0, 0))
im2.save(‘D:\Desktop\python学习\ans.jpg’)
############### 11 ###########################
import requests
import urllib.request as ur
from PIL import Image
im = Image.open(“D:\Desktop\python学习\cave.jpg”)
(w, h) = im.size
im2 = Image.new(im.mode, (w, h))
for i in range(0, h):
end = w//2
start = 0
for j in range(0, w):
if (i + j)%2 == 0:
pixel = im.getpixel((j,i))
im2.putpixel((end,i),pixel)
end = end + 1
else:
pixel = im.getpixel((j, i))
im2.putpixel((start, i), pixel)
start = start + 1
im2.save(“D:\Desktop\python学习\10ans.jpg”)
################### 12 ###############################
import requests
import pickle
import re
f = open(“D:\Desktop\python学习\evil2.gfx”, ‘rb’)
content = f.read()
for i in range(0,5):
l = content[i::5]
ff = open(f"D:\Desktop\python学习{i}.jpeg",“wb”)
ff.write(l)
#################### 13 #########################
from xmlrpc.client import ServerProxy
server = ServerProxy(“http://www.pythonchallenge.com/pc/phonebook.php”)
response = server.phone(“Bert”)
print(response)
############# 14 #######################
from PIL import Image
im = Image.open(“D:\Desktop\python学习\wire.png”)
(w, h) = im.size
w2 = h2 = 100
im2 = Image.new(im.mode,(w2,h2))
a = 0
b = w2
c = 0
d = h2
n = 0
num = 0
print(im.getpixel((num, 0)))
for j in range(0,w2//2):
n +=1
print(n)
for i in range(a, b):
im2.putpixel((i, c), im.getpixel((num, 0)))
num += 1
for i in range(c+1, d):
im2.putpixel((b-1, i), im.getpixel((num, 0)))
num += 1
for i in range(b-2, a, -1):
im2.putpixel((i, d-1), im.getpixel((num, 0)))
num += 1
for i in range(d-1, c, -1):
im2.putpixel((a, i), im.getpixel((num, 0)))
num += 1
a += 1
b -= 1
c += 1
d -= 1
im2.save(“D:\Desktop\python学习\14ans.png”)
########### 15 ###################
import calendar
from datetime import date
d = date(1006,1,1)
while d.year<1997:
if d.isoweekday() == 4 and calendar.isleap(d.year):
print(d.year)
d = d.replace(year=d.year + 10)
############ 16 ###############
from PIL import Image
im = Image.open(“D:\Desktop\python学习\mozart.gif”)
im2 = im
(w,h) = im.size
for i in range(0,h):
nw = 0
nh = i
j = 0
while j < w:
pixel = im.getpixel((j,i))
if pixel == 195:
start = j + 5
end = j -1
for k in range(start,w):
im2.putpixel((nw,nh),im.getpixel((k,i)))
nw += 1
for kk in range(0,end+1):
im2.putpixel((nw, nh), im.getpixel((kk, i)))
nw += 1
break
j += 1
im2.save(“D:\Desktop\python学习\16ans.gif”)
##################### 17########################
import requests
import re
import http.cookiejar
import urllib .request
from urllib import parse
import bz2
ans = “12345”
# key = [‘44827’]
number = re.compile("\d+")
info = “”
while True:
r = requests.get( “http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing=” + ans)
t = r.text
key = re.findall(“the next busynothing is \d+”, str(t)) # 返回值为列表
num = re.findall(number,’’.join(key))
if num:
cookie = http.cookiejar.MozillaCookieJar() # 创建cookiejar的实例来保存cookie
handler = urllib .request.HTTPCookieProcessor(cookie) # 创建一个处理器处理cookie
opener = urllib.request.build_opener(handler) # 创建一个opener,使用opener访问url,就会将网页中的cookie保存到变量cookie中
url = “http://www.pythonchallenge.com/pc/def/linkedlist.php?busynothing=” + ans
res = opener.open(url)
# print(res.read())
for i in cookie:
print(3)
if i.name == “info”:
print(i.value)
info += i.value
ans = ‘’.join(num)
# print(ans)
# print(str(t))
else:
print(str(t))
# ans = str(int(ans)/2)
break
print(info)
# ina = “BZh91AY%26SY%94%3A%E2I%00%00%21%19%80P%81%11%00%AFg%9E%A0+%00hE%3DM%B5%23%D0%D4%D1%E2%8D%06%A9%FA%26S%D4%D3%21%A1%EAi7h%9B%9A%2B%BF%60%22%C5WX%E1%ADL%80%E8V%3C%C6%A8%DBH%2632%18%A8x%01%08%21%8DS%0B%C8%AF%96KO%CA2%B0%F1%BD%1Du%A0%86%05%92s%B0%92%C4Bc%F1w%24S%85%09%09C%AE%24%90”
# ina = ina.replace("+", “%20”)
# ina = parse.unquote_to_bytes(ina)
# ina = bz2.decompress(ina).decode()
# print(ina)
import this
python challenge相关推荐
- (转)一个古老的编程游戏:Python Challenge全通攻略
为什么80%的码农都做不了架构师?>>> Python Challenge是一个网页闯关游戏,通过一些提示找出下一关的网页地址.与众不同的是,它是专门为程序员设计的,因为大多数 ...
- the python challenge_The Python Challenge 谜题全解(持续更新)
Python Challenge(0-2) 是个很有意思的网站,可以磨练使用python的技巧,每一关都有挑战,要编写相应的代码算出关键词,才可以获取下一关的url,还是很好玩的QAQ LEVEL 0 ...
- Python Challenge 过关心得(0)
最近开始用Openerp进行开发,在python语言本身上并没有什么太大的进展,于是决定利用空闲时间做一点python练习. 最终找到了这款叫做Python Challenge(http://www. ...
- 有趣的Python Challenge编程解谜游戏攻略二(5-9关)
**有趣的Python Challenge编程解谜游戏攻略二(5-9关)** 介绍 游戏介绍 0-4关攻略 写在前面 关卡 第5关 第6关 第7关 第8关 第9关 链接总结 第10关预告 介绍 游戏介 ...
- Python challenge 全部题解
Python Challenge http://www.pythonchallenge.com/ http://garethrees.org/2007/05/07/python-challenge/ ...
- 转:一个古老的编程游戏:Python Challenge全通攻略
Python Challenge是一个网页闯关游戏,通过一些提示找出下一关的网页地址.与众不同的是,它是专门为程序员设计的,因为大多数关卡都要编程来算哦!! 去年和同学一起玩的,他做了大半,我做了小半 ...
- [转]一个古老的编程游戏:Python Challenge全通攻略
Python Challenge是一个网页闯关游戏,通过一些提示找出下一关的网页地址.与众不同的是,它是专门为程序员设计的,因为大多数关卡都要编程来算哦!! 去年和同学一起玩的,他做了大半,我做了小半 ...
- Python Challenge全解(持续更新中)
有趣的Python Challenge编程游戏闯关攻略一(0-4关) 有趣的Python Challenge编程解谜游戏攻略二(5-9关) 有趣的Python Challenge编程解谜游戏第10关 ...
- the python challenge_The Python Challenge
Python是著名的「龟叔」Guido van Rossum在1989年圣诞节期间,为了打发无聊的圣诞节而编写的一个编程语言,从诞生之初就显得有些随意. 说实话我们都或多或少有些厌烦那些复杂的语法,或 ...
- the python challenge_The Python Challenge 解密之旅
本文是记录博主运用 Python 来解决 The Python Challenge 站点中每个关卡的难题. 说明:本文为博主自主原创,允许转载,但是必须标明来源出处及其作者,谢谢! The Pytho ...
最新文章
- vue+vant使用图片预览功能ImagePreview的问题
- 基于python的界面自动化测试-基于Python语言的自动化测试实战第二章(上)
- 关于c++静态成员函数
- final关键字的深入理解
- 7-二进制,十进制,十六进制
- 函数体中定义的结构体和类型
- docker file 示例
- oracle 索引 序列,【Oracle】表、视图、序列、索引
- 代码片段:基于 JDK 8 time包的时间工具类 TimeUtil
- Python整理PEER所下载的地震波源数据——提取地震波至txt+生成地震波反应谱
- 达摩达兰论估价pdf_故事与估值epub+azw3+mobi文字版pdf+txt多看word魔鸠搜雅书屋
- 微信H5分享、复制链接遇到的坑
- win10浏览器闪退_Win10电脑的自带浏览器闪退怎么办?其实简单四步就可解决!...
- 你还把游戏本地化当作是游戏翻译
- macos支持exfat吗_你需要黑苹果吗?
- 两年数据对比柱形图_【系列课程】用Excel进行数据可视化组合图表的制作lt;二gt;...
- 惠普服务器dl388g7光盘引导,hp dl388g7 无光驱怎么安装系统
- 大数据平台的软件有哪些?
- 基于summernote的富文本编辑器,粘贴时去除word格式
- 国庆佳节第四天,谈谈我月收入增加 4K 的故事
热门文章
- Python学习笔记(11) 如何用爬虫完整抓取搜狐新闻文章?
- @Pattern进行正则校验
- 无焦点显示窗口解决方法 [转]AttachThreadInput的用法
- java数字排序方法_常见的数据排序方法
- java猜十二生肖_猜一肖猜十二生肖其中一只,并说明理由 – 手机爱问
- 【信息技术】目标跟踪方法及其应用领域:元分析
- 网络相关linux指令等储备
- QPrinter QPrintDialog QPrintPreviewDialog 打印PDF文件
- ubuntu系统下,安装pycharm以及创建桌面快捷方式
- 【新技术】语音到语音翻译 Speech-to-speech translation for a real-world unwritten language