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/ 接下来会写破解教程~
随机推荐
- python把日期转换为秒数;日期转为字符串;datetime、date
1.秒数是相对于1970.1.1号的秒数 2.日期的模块有time.datetime 3. import datetime t = datetime.datetime(2009, 10, 21, 0, ...
- 体验Windows 2008 R2的RemoteApp
[说明]这是<中小企业虚拟机解决方案大全>一书中部分章节的摘抄.该书预计于2009年12月初由<电子工业出版社>出版,敬请期待! 通过远程桌面服务,组织可以为用户提供随时随 ...
- python 工具 FFT变换
import numpy as npimport pylabwave_data =np.fromfile("C:\\Users\\Administrator\\Desktop\\bins\\ ...
- 关于Memcached的CAS和Set方法造成Socket泄漏的问题
为了解决多并发下写Memcached的冲突方案,我们项目组引入了CAS机制.类同于Java并发包中的CAS(Compareand set)原子操作,用来处理同一个Item被多个线程更改的并发问题.Me ...
- [CSS3] Target HTML Elements not Explicitly set in the DOM with CSS Pseudo Elements (Blockquotes)
Pseudo elements allow us to target elements that are not explicitly set in the DOM. Using ::before : ...
- vue2.0 自定义过滤器(filter)实例
一.过滤器简介 (1)过滤器创建 过滤器的本质 是一个有参数 有返回值的方法 new Vue({ filters:{ myCurrency:function(myInput){ return 处理后的 ...
- vc++6.0中右键点击"转到定义"为什么是"未定义符号"呢?
VC的问题,需要生成一下浏览信息...然后rebuild
- Qt5官方demo解析集13——Qt Quick Particles Examples - Image Particles
本系列全部文章能够在这里查看http://blog.csdn.net/cloud_castle/article/category/2123873 接上文 Qt5官方demo解析集12--Qt Quic ...
- 20170301 Excel 导出函数XXL_SIMPLE_API
* XMPLT_V-COL_NO = . * XMPLT_V-COL_NAME = '物料号码'. * APPEND XMPLT_V. * * XMPLT_V-COL_NO = . * XMPLT_V ...
- Ubuntu下如何安装并使用Objective-C
Objective-C是本人用过的最佳类C.面向对象的编程语言.Objective-C与标准C完美兼容,而在此基础上又加上了将面向对象的基础概念诠释得最好的SmallTalk元素,使得它既简洁.又灵活 ...