文本處理 (Text Processing) 服務¶
本章節介紹的模組 (module) 提供了廣泛的字串操作與其他文本處理服務。
在 二進位資料服務 下所描述的 codecs 模組也與文本處理高度相關。另外也請參閱在 Text Sequence Type --- str 中所描述的 Python 內建字串型別。
string--- 常見的字串操作re--- 正規表示式 (regular expression) 操作difflib--- Helpers for computing deltasDifferHtmlDiffcontext_diff()get_close_matches()ndiff()restore()unified_diff()diff_bytes()IS_LINE_JUNK()IS_CHARACTER_JUNK()- SequenceMatcher 物件
SequenceMatcherSequenceMatcher.set_seqs()SequenceMatcher.set_seq1()SequenceMatcher.set_seq2()SequenceMatcher.find_longest_match()SequenceMatcher.get_matching_blocks()SequenceMatcher.get_opcodes()SequenceMatcher.get_grouped_opcodes()SequenceMatcher.ratio()SequenceMatcher.quick_ratio()SequenceMatcher.real_quick_ratio()
- SequenceMatcher 範例
- Differ Objects
- Differ Example
- A command-line interface to difflib
- ndiff 範例:
textwrap--- Text wrapping and fillingwrap()fill()shorten()dedent()indent()TextWrapperTextWrapper.widthTextWrapper.expand_tabsTextWrapper.tabsizeTextWrapper.replace_whitespaceTextWrapper.drop_whitespaceTextWrapper.initial_indentTextWrapper.subsequent_indentTextWrapper.fix_sentence_endingsTextWrapper.break_long_wordsTextWrapper.break_on_hyphensTextWrapper.max_linesTextWrapper.placeholderTextWrapper.wrap()TextWrapper.fill()
unicodedata--- Unicode Databasestringprep--- Internet String Preparationreadline--- GNU readline interfacerlcompleter--- Completion function for GNU readline