gist: https://gist.github.com/genesislive/5097326
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# http://www.pythonchallenge.com/pc/def/ocr.html
import re
# the content of rare_characters.txt is from the
# source of ocr.html
with open('rare_characters.txt', 'r') as file1:
content = file1.read()
print ''.join(re.findall('[A-Za-z]', content))
本文介绍了一个使用Python解决的挑战任务,从一个包含罕见字符的文本文件中提取所有英文字母字符。通过Python的正则表达式模块re实现,最终输出纯净的字母字符串。
2237

被折叠的 条评论
为什么被折叠?



