pythonchallenge 2
pythonchallenge是一个很有意思的学习python的网站,通过用程序解开一个谜,可以进入到下一个level,总共有几十个level,网址是http://www.pythonchallenge.com。很早就知道这个网站了,一直放在书签里没动,最近下定决心要学习python了,心血来潮决定玩玩这个网站。level0和level1都挺简单的(其实level2也挺简单的),就从level2开始记录我的历程吧。
我的python代码如下:
import urllib2
content=urllib2.urlopen('http://www.pythonchallenge.com/pc/def/ocr.html').read()
content=content[content.find('<!--',800)+4:len(content)-5]
dict1={}
for c in content:
if c in dict1:
dict1[c]+=1
else:
dict1[c]=1;
dict2= sorted(dict1.iteritems(), key=lambda d:d[1], reverse = True)
print dict2
思路就是,题目其实藏在网页源码里,是一串特别特别长的字符串,从中找出几个低频的字符,我懒得copy那段字符了,直接用python库利用url取得html代码,从中截取出那段字符,再使用一个dict来记录每个字符出现的次数,最后将dict排序,最后的输出是
[(')', 6186), ('@', 6157), ('(', 6154), (']', 6152), ('#', 6115), ('_', 6112), ('[', 6108), ('}', 6105), ('%', 6104), ('!', 6079), ('+', 6066), ('$', 6046), ('{', 6046), ('&', 6043), ('*', 6034), ('^', 6030), ('\n', 1221), ('a', 1), ('e', 1), ('i', 1), ('l', 1), ('q', 1), ('u', 1), ('t', 1), ('y', 1)]
频率最低的几个词组成的单词是equality,所以level2的解题url是http://www.pythonchallenge.com/pc/def/equality.html。
pythonchallenge 2的更多相关文章
- pythonchallenge 解谜 Level 8
#-*- coding:utf-8 -*- #代码版本均为python 3.5.1 #Level 7 import bz2 un=b'BZh91AY&SYA\xaf\x82\r\x00\x00 ...
- pythonchallenge 解谜 Level 7
#-*- coding:utf-8 -*- #代码版本均为python 3.5.1 #Level 7 from PIL import Image x_begin, x_end = 0, 609 y_b ...
- pythonchallenge 解谜 Level 6
第六关地址 http://www.pythonchallenge.com/pc/def/channel.html 和前几关一样,首先看网页源码吧.反正不看也没办法... <html>< ...
- pythonchallenge 解谜 Level 5
第五关的确很坑爹... 不过,根据之前的思路,我想着是把信息放在了 “源码” 中. 翻了下源码.有用的东西在以下部分. <html><head> <title>pe ...
- pythonchallenge 解谜 Level 4
下一关... 一张图片,于是就点击了一下. 跳转到了 http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=12345 显示的是: ...
- pythonchallenge 解谜 Level 3
第三关. 问题的解法在于正则表达式. 首先...你应该能找到需要正则的字符在哪里...那就好了! 题意就是说: One small letter, surrounded by EXACTLY thre ...
- pythonchallenge 解谜 Level 2
好吧,赶紧贴一下. #-*- coding:utf-8 -*- #代码版本均为python 3.5.1 #Level 2 import re file = open("Level 2.txt ...
- pythonchallenge 解谜 Level 1
得到第一关地址后可以进行第一关的解析了. 看起来好神秘的样子.但是也就是把字母 k 变成 m , o 变成 q ,e 变成 g.将字母对应的ASCII的值+2就行了. #-*- coding:utf- ...
- pythonchallenge 解谜 Level 0
解谜地址: http://www.pythonchallenge.com/pc/def/0.html 这题没什么难度,意思就是得到2的38次方的值,然后,替换 http://www.pythoncha ...
- pythonchallenge 解谜
所有代码均使用python 3.5.1 版本 最近在学python,闲来无事觉得这个解谜还挺有意思. 解谜网址 http://www.pythonchallenge.com/ 接下来会写破解教程~
随机推荐
- 跟阿根一起学Java Web开发一:开发环境搭建及JSPGen基础配置
JSPGenSDF软件开发框架(于2014年5月5号公布4.0版).简称JSPGen,专用Java Web方面平台式软件开发,整个框架也能够说是前台与后台的一个粘合剂,如今对JSPGenSDF进行开发 ...
- leetcode Valid Palindrome C++&python 题解
题目描写叙述 Given a string, determine if it is a palindrome, considering only alphanumeric characters and ...
- onlyOffice 开发相关 总结
onlyOffice 服务端 客户端 相关开发整理 功能: 所有客户端都可用 云端部署服务 查看 预览 doc ppt excel 编辑 权限控制 开发技术准备 用户服务器端 提供保存接口 用户浏览器 ...
- 玩转Bash脚本:循环结构之while循环(转)
转自:http://blog.csdn.net/guodongxiaren/article/details/43341769 总第8篇 本系列(玩转Bash脚本)更多文章,请访问:http://b ...
- C# - CLR
The Common Language Runtime (CLR), the virtual-machine component of Microsoft's .NET framework, m ...
- c程序设计语言第一章4
(昨天网络出现了问题,导致这篇没来得及上传,再次补上,今晚照常上传笔记) 练习1.19编写函数r e v e r s e ( s )将字符串s中的字符顺序颠倒过来.使用该函数编写一个程序,每次颠倒一个 ...
- 走入asp.net mvc不归路:[5]Action的返回
asp.net mvc提供了多种返回方式,一方面使得视图可以重用,另一方面灵活强大,有直接返回视图,返回Json,返回文件流,返回到相同Controller的Action,返回到另一个Controll ...
- PHP通用分页
php通用分页,先看下样式 代码如下: <style> body { font-size:12px;font-family:verdana;width:100%; } div.page{ ...
- 第8章4节《MonkeyRunner源代码剖析》MonkeyRunner启动执行过程-启动AndroidDebugBridge
上一节我们看到在启动AndroidDebugBridge的过程中会调用其start方法,而该方法会做2个基本的事情: 715行startAdb:开启AndroidDebugBridge 722-723 ...
- Yarn调度器负载模拟器——Yarn Scheduler Load Simulator (SLS)
一.概述: Yarn调度器有很多实现,如Fifo, Capacity和Fair schedulers等.与其同一时候,正在进行一些优化措施来提高调度器在不同负载和工作场景下的性能.每一个调度器都有自己 ...