Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2008-04-16 02:13:30
Size: 1810
Editor: JinQing
Comment:
Revision 3 as of 2009-11-28 23:05:17
Size: 1806
Editor: Elias
Comment: 删除对PageComment2组件的引用
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
[[BR]][[BR]]
Line 64: Line 65:
[[PageComment2]]

::-- JinQing [DateTime(2008-04-16T02:13:30Z)] BRBR

21.2. Strategies for Parsing Text in Python BRBR

21.2. 用Python解析文本的策略 BRBR

In the grand scheme of things, there are a variety of ways to handle text processing in Python: BRBR

从整体看,Python处理文本有多种方式: BRBR

    • Built-in string object expressions
    • 内置的字符串对象表达式
    • String object method calls
    • 字符串对象方法调用
    • Regular expression matching
    • 正则表达式匹配
    • Parser-generator integrations
    • 解析器生成器集成
    • Handcoded and generated parsers
    • 手工编码的和自动生成的解析器
    • Running Python code with eval and exec built-ins
    • 用内置的eval和exec运行Python代码

BRBR For simpler tasks, Python's built-in string object is often all we really need. Python strings can be indexed, concatenated, sliced, and processed with both string method calls and built-in functions. Our emphasis in this chapter, though, is on higher-level tools and techniques for analyzing textual information. Let's briefly explore each of the other approaches with representative examples. BRBR

对于较简单的任务,我们往往只需Python内置的字符串对象。 Python的字符串可以进行索引、拼接、切片,并且可用字符串方法和内置函数进行处理。然而,本章的重点是,分析文本信息的高级工具和技术。让我们以代表性的例子,简要地探索各种方法。 BRBR

评译

PP3eD/Ch-21-2 (last edited 2009-12-25 07:13:57 by localhost)