Python Challenge Level 2

http://www.pythonchallenge.com/pc/def/ocr.html

查看页面源代码后,发现了一堆乱码。。有一句话很重要:find rare cha­ra­cters in the mess below。题目是要我们在这堆乱码中找出仅有的几个字符。。

string模块里有个isalpha函数,来确定一个字符是否是字母。这次派上用场了。

源代码:

content='''......'''

import string
result=[c for c in content if c.isalpha()]
print string.join(result,'')

结果:

equa­lity

No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>