PythonChallenge Level 0~4

PythonChallenge Level 0:    http://www.pythonchallenge.com/pc/def/0.html

    

 

    计算 2 的 38 次幂 将得到的结果替换URL中数字0

print 2**38

 

 

 

 

 

 

PythonChallenge Level 1:    http://www.pythonchallenge.com/pc/def/map.html


 

照笔记本中给出的规律解密图片下方给出的一串字符

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.
     用到两个函数

string. maketrans ( fromto )

Return a translation table suitable for passing to translate(), that will map each character in from into the character at the same position in tofrom and to must have the same length.

##返回一个转换表 table( eg. 'A'-->'a', 'B'-->'b'), from 和 to 长度必须一致,在 from 中有的字符转换成 to 中对应位置的字符 

string. translate ( stable[,  deletechars] )

Delete all characters from s that are in deletechars (if present), and then translate the characters using table, which must be a 256-character string giving the translation for each character value, indexed by its ordinal. If table is None, then only the character deletion step is performed.

##按照转换表 table,对字符串 s 进行转换

 

import string

#load the text 
text = '''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.
'''

#creat a translate table
table = string.maketrans(string.ascii_lowercase, string.ascii_lowercase[2:] + string.ascii_lowercase[:2])

#apply the translation table on string
print string.translate(text, table)

# Or you can "print text.translate(table)"

 if you don't know  "string.ascii_lowercase[2:]", "string.ascii_lowercase[:2]", "string.ascii_lowercase",  try to print it. 

 

执行结果:i hope you didnt translate it by hand. thats what computers are for.

doing it in by hand is inefficient and that's why this text is so long. 

using string.maketrans() is recommended. now apply on the url.(对Level 1 URL中 map 进行同样替换即可转至Level 2)

 

 

 

 

 

 

PythonChallenge Level 2:    http://www.pythonchallenge.com/pc/def/ocr.html

 

    

 

网页的左下角还有几条提示

General tips:

  • Use the hints. They are helpful, most of the times.
  • Investigate the data given to you.
  • Avoid looking for spoilers.

 We saw the hint “but MABYE they are in the page source” 

故执行: 右击网页 --> 查看网页源代码 

找到了这一关的谜题: find rare characters in the mess below:

 

用到一个 str.isalpha() 函数,判断是否字母

str. isalpha ( )

Return true if all characters in the string are alphabetic and there is at least one character, false otherwise.

For 8-bit strings, this method is locale-dependent.

 

import string

mess = ''' #copy the mess from Level.2's page source '''
ans = ''

for x in mess:
    if x.isaplha():
        ans += x

print ans

 

得到结果: equality

将其替换 Level 2 URL 中的 " ocr " 即转到level 3

 

 

 

 

 

PythonChallenge Level 3:    http://www.pythonchallenge.com/pc/def/equality.html


网页左下角内容

To see the solutions to the previous level, replace pc with pcc, i.e. go to: http://www.pythonchallenge.com/pcc/def/equality.html 

Join us on IRC: irc.freenode.net #pythonchallenge

网页左下角的内容与本题无关,但从句中'see the solutions to the previious level'中得到启发,同第二关一样查看了网页的源代码,其中果然给出了mess.

图片正下方提示

One small letter, surrounded by EXACTLY three big bodyguards on each of its sides.

一个小写字母两边都有三个大写字母,形如 XXXxXXX ,后经尝试并不能得到结果,搜索之,其他过关的人用来匹配的形式为 xXXXxXXXx ,虽然还没明白为何如此,但确实是到下一关的正确方向。

从给出的mess中找出xXXXxXXXx形式的字符,用到网页源代码获取模块Urllib2以及正则表达式re模块。

urllib2. urlopen ( url[, data[, timeout[, cafile[, capath[, cadefault[, context]]]]] )

Open the URL url, which can be either a string or a Request object.

data may be a string specifying additional data to send to the server, or None if no such data is needed. Currently HTTP requests are the only ones that use data; the HTTP request will be a POST instead of a GET when the data parameter is provided. data should be a buffer in the standard application/x-www-form-urlencoded format. The urllib.urlencode() function takes a mapping or sequence of 2-tuples and returns a string in this format. urllib2 module sends HTTP/1.1 requests with Connection:close header included.

The optional timeout parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used). This actually only works for HTTP, HTTPS and FTP connections.

If context is specified, it must be a ssl.SSLContext instance describing the various SSL options. See HTTPSConnection for more details.

The optional cafile and capath parameters specify a set of trusted CA certificates for HTTPS requests. cafile should point to a single file containing a bundle of CA certificates, whereas capath should point to a directory of hashed certificate files. More information can be found in ssl.SSLContext.load_verify_locations().

The cadefault parameter is ignored.

This function returns a file-like object with three additional methods:

  • geturl() — return the URL of the resource retrieved, commonly used to determine if a redirect was followed
  • info() — return the meta-information of the page, such as headers, in the form of an mimetools.Message instance (see Quick Reference to HTTP Headers)
  • getcode() — return the HTTP status code of the response.

Raises URLError on errors.

Note that None may be returned if no handler handles the request (though the default installed global OpenerDirector uses UnknownHandlerto ensure this never happens).

In addition, if proxy settings are detected (for example, when a *_proxy environment variable like http_proxy is set), ProxyHandler is default installed and makes sure the requests are handled through the proxy.

Changed in version 2.6: timeout was added.

Changed in version 2.7.9: cafilecapathcadefault, and context were added.

 

re. findall ( patternstringflags=0 )

Return all non-overlapping matches of pattern in string, as a list of strings. The string is scanned left-to-right, and matches are returned in the order found. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result unless they touch the beginning of another match.

New in version 1.5.2.

Changed in version 2.4: Added the optional flags argument.

 

import urllib2
import re
import string

text = urllib2.urlopen('http://www.pythonchallenge.com/pc/def/equality.html').read()
matstr = re.findall(r'[a-z][A-Z]{3}[a-z][A-Z]{3}[a-z]', text)
ans = ''
i = 0
while i < len(matstr):
    ans += matstr[i][4]
    i += 1
print ans








 

基于找出的匹配字符需有意义的角度,最后的ans只提取了xXXXxXXXx形式中间的小写字母

代码运行结果为 linkedlist 按照前几题的经验,替换Level 3中equality回车得到提示“linkedlist.php”,按提示再次替换html为php即转至Level 4

 

 

 

 

 

PythonChallenge Level 4:    http://www.pythonchallenge.com/pc/def/linkedlist.php

给了一幅没怎么看得懂的图,查看是否有隐藏提示于网页源代码中,右击-->查看网页源代码  如下

<html>
<head>
  <title>follow the chain</title>
  <link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<!-- urllib may help. DON'T TRY ALL NOTHINGS, since it will never 
end. 400 times is more than enough. -->
<center>
<a href="linkedlist.php?nothing=12345"><img src="chainsaw.jpg" border="0"/></a>
<br><br><font color="gold"></center>
Solutions to previous levels: <a href="http://wiki.pythonchallenge.com/"/>Python Challenge wiki</a>.
<br><br>
IRC: irc.freenode.net #pythonchallenge
</body>
</html>

 主题“follow the chain”,注释“ urllib may help. DON'T TRY ALL NOTHINGS, since it will never end. 400 times is more than enough.”,另分析源代码可知网页中图片添加了超链接herf="linkedlist.php?nothing=12345",返回点击图片得到文本提示"and the next nothing is 44827"。

综上分析明白了Level 4 题面要做的就是递归更换 网页图片超链接URL中的nothing值

import urllib2
import string

urLstr = 'http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing='

def get_Nothings(uid):
    if uid.isdigit():
        text = urllib2.urlopen(urLstr+uid).read()
        # print text
        nextuid = ''
        for x in text:
            if x.isdigit():
                nextuid += x 
        # print urLstr + uid             
        print urllib2.urlopen(urLstr+uid).read(),'\n'
        return get_Nothings(nextuid)
    else:
        pass
get_Nothings("12345") 

 代码运行一小段时间出现非数字给出nothing值的情况,提示“Yes,Divide by two and keep going”

将在其前的nothing值 16044 除以 2 即 8022 作为代码中函数get_Nothings()的初始值继续运行。

最后得到Level 4的结果 peak.html 将其替换到URL中即转至Level 5

Level 5 :http://www.pythonchallenge.com/pc/def/peak.html

Level 5~10 解题过程会记录在我的下一篇博客中,谢谢!-------by 江南

 

                

 
 

 

 

 

 

标题基于SpringBoot+Vue的社区便民服务平台研究AI更换标题第1章引言介绍社区便民服务平台的研究背景、意义,以及基于SpringBoot+Vue技术的研究现状和创新点。1.1研究背景与意义分析社区便民服务的重要性,以及SpringBoot+Vue技术在平台建设中的优势。1.2国内外研究现状概述国内外在社区便民服务平台方面的发展现状。1.3研究方法与创新点阐述本文采用的研究方法和在SpringBoot+Vue技术应用上的创新之处。第2章相关理论介绍SpringBoot和Vue的相关理论基础,以及它们在社区便民服务平台中的应用。2.1SpringBoot技术概述解释SpringBoot的基本概念、特点及其在便民服务平台中的应用价值。2.2Vue技术概述阐述Vue的核心思想、技术特性及其在前端界面开发中的优势。2.3SpringBoot与Vue的整合应用探讨SpringBoot与Vue如何有效整合,以提升社区便民服务平台的性能。第3章平台需求分析与设计分析社区便民服务平台的需求,并基于SpringBoot+Vue技术进行平台设计。3.1需求分析明确平台需满足的功能需求和性能需求。3.2架构设计设计平台的整体架构,包括前后端分离、模块化设计等思想。3.3数据库设计根据平台需求设计合理的数据库结构,包括数据表、字段等。第4章平台实现与关键技术详细阐述基于SpringBoot+Vue的社区便民服务平台的实现过程及关键技术。4.1后端服务实现使用SpringBoot实现后端服务,包括用户管理、服务管理等核心功能。4.2前端界面实现采用Vue技术实现前端界面,提供友好的用户交互体验。4.3前后端交互技术探讨前后端数据交互的方式,如RESTful API、WebSocket等。第5章平台测试与优化对实现的社区便民服务平台进行全面测试,并针对问题进行优化。5.1测试环境与工具介绍测试
资源下载链接为: https://pan.quark.cn/s/9648a1f24758 Java中将Word文档转换为PDF是一种常见的技术需求,尤其在跨平台共享、保持格式一致性和便于在线预览等场景中非常实用。通常,开发者会借助专门的库来实现这一功能,其中Aspose.Words是一个非常强大的选择。Aspose.Words是由Aspose公司开发的文档处理组件,支持多种文件格式,包括Word和PDF。它提供了丰富的API,方便开发者在Java应用程序中进行文件转换、编辑和格式化操作,尤其在Word转PDF方面表现卓越。 使用Aspose.Words进行Word转PDF的步骤如下: 添加依赖:通过Maven或Gradle等工具将Aspose.Words的Java库引入项目。 加载Word文档:使用Document类加载Word文件,例如: 配置输出选项:创建PdfSaveOptions对象,用于设置PDF保存时的选项,如图像质量、安全性等。 执行转换:调用Document的save方法,传入输出路径和PdfSaveOptions对象,例如: 支持多种输出格式:Aspose.Words不仅支持将Word转换为PDF,还能转换为HTML、EPUB、XPS等多种格式,只需更换SaveOptions的子类即可。 保持格式与样式:在转换过程中,Aspose.Words能够最大程度地保留源文档的格式和样式,包括文本样式、图像位置、表格布局等。 优化性能:Aspose.Words支持并行处理和多线程技术,可以显著提高大量文档转换的速度。 处理复杂文档:它能够处理包含宏、复杂公式、图表、脚注等元素的Word文档,确保转换后的PDF内容完整且可读。 安全性与版权:在转换过程中,可以设置PDF的访问权限,例如禁止打印或复制文本,从而保护文档内容。 在实际开发中,还需要注意错误和异常的处理,以
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值