Python 标准库参考指南 2.7.18 视为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): group(0)[0].upper() + ... mo.group(0)[1:].lower(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." For 8-bit strings, this method is locale-dependent. str.translate(table[ 本模块还提供了以下常量,适用于读取和写入依赖于平台的文件: codecs.BOM codecs.BOM_BE codecs.BOM_LE codecs.BOM_UTF8 codecs.BOM_UTF16 codecs.BOM_UTF16_BE codecs.BOM_UTF16_LE codecs.BOM_UTF32 codecs.BOM_UTF32_BE 120 Chapter 7. String Services0 码力 | 1552 页 | 7.42 MB | 9 月前3
Python 标准库参考指南 2.7.18 视为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): group(0)[0].upper() + ... mo.group(0)[1:].lower(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." For 8-bit strings, this method is locale-dependent. str.translate(table[ 本模块还提供了以下常量,适用于读取和写入依赖于平台的文件: codecs.BOM codecs.BOM_BE codecs.BOM_LE codecs.BOM_UTF8 codecs.BOM_UTF16 codecs.BOM_UTF16_BE codecs.BOM_UTF16_LE codecs.BOM_UTF32 codecs.BOM_UTF32_BE 120 Chapter 7. String Services0 码力 | 1552 页 | 7.42 MB | 9 月前3
Python 标准库参考指南 2.7.18 视为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): group(0)[0].upper() + ... mo.group(0)[1:].lower(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." For 8-bit strings, this method is locale-dependent. str.translate(table[ 本模块还提供了以下常量,适用于读取和写入依赖于平台的文件: codecs.BOM codecs.BOM_BE codecs.BOM_LE codecs.BOM_UTF8 codecs.BOM_UTF16 codecs.BOM_UTF16_BE codecs.BOM_UTF16_LE codecs.BOM_UTF32 codecs.BOM_UTF32_BE 120 Chapter 7. String Services0 码力 | 1552 页 | 7.42 MB | 9 月前3
Python 标准库参考指南 3.6.15 视为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): group(0)[0].upper() + ... mo.group(0)[1:].lower(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." str.translate(table) 返 回 原 字 符 串 的 副 本, 其 中 每 个 字 符 按 给 定 的 转 换 表 进 行 映 bytearray, memoryview 59 The Python Library Reference, 发布 3.6.15 >>> b"they're bill's friends from the UK".title() b"They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s):0 码力 | 1886 页 | 8.95 MB | 9 月前3
Python 标准库参考指南 3.6.15 视为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): group(0)[0].upper() + ... mo.group(0)[1:].lower(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." str.translate(table) 返 回 原 字 符 串 的 副 本, 其 中 每 个 字 符 按 给 定 的 转 换 表 进 行 映 bytearray, memoryview 59 The Python Library Reference, 发布 3.6.15 >>> b"they're bill's friends from the UK".title() b"They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s):0 码力 | 1886 页 | 8.95 MB | 9 月前3
Python 标准库参考指南 3.7.13 视为单词。该定义在多数情况下都很 有效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): group(0)[0].upper() + ... mo.group(0)[1:].lower(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." str.translate(table) 返回原字符串的副本,其中每个字符按给定的转换表进行映射。转换表必须是一个使用 __getitem__() 为单词。该定义在多数情况下都很 有效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> b"they're bill's friends from the UK".title() b"They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s):0 码力 | 1846 页 | 9.09 MB | 9 月前3
Python 标准库参考指南 3.7.13 视为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): group(0)[0].upper() + ... mo.group(0)[1:].lower(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." str.translate(table) 返 回 原 字 符 串 的 副 本, 其 中 每 个 字 符 按 给 定 的 转 换 表 进 行 映 为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> b"they're bill's friends from the UK".title() b"They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s):0 码力 | 1961 页 | 9.14 MB | 9 月前3
Python 标准库参考指南 3.8.20 视为单词。该定义在多数情况下都很 有效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): +)?", ... lambda mo: mo.group(0).capitalize(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." str.translate(table) 返回原字符串的副本,其中每个字符按给定的转换表进行映射。转换表必须是一个使用 __getitem__() 为单词。该定义在多数情况下都很 有效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> b"they're bill's friends from the UK".title() b"They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s):0 码力 | 1927 页 | 9.69 MB | 9 月前3
Python 标准库参考指南 3.8.20 视为单词。该定义在多数情况下都很 有效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): +)?", ... lambda mo: mo.group(0).capitalize(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." str.translate(table) 返回原字符串的副本,其中每个字符按给定的转换表进行映射。转换表必须是一个使用 __getitem__() 为单词。该定义在多数情况下都很 有效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> b"they're bill's friends from the UK".title() b"They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s):0 码力 | 1927 页 | 9.69 MB | 9 月前3
Python 标准库参考指南 3.8.20 视为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> "they're bill's friends from the UK".title() "They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s): (续上页) ... lambda mo: mo.group(0).capitalize(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." str.translate(table) 返 回 原 字 符 串 的 副 本, 其 中 每 个 字 符 按 给 定 的 转 换 表 进 行 映 为单词。该定义在多数情况下都很有 效,但它也意味着代表缩写形式与所有格的撇号也会成为单词边界,这可能导致不希望的结果: >>> b"they're bill's friends from the UK".title() b"They'Re Bill'S Friends From The Uk" 可以使用正则表达式来构建针对撇号的特别处理: >>> import re >>> def titlecase(s):0 码力 | 2052 页 | 9.74 MB | 9 月前3
共 154 条
- 1
- 2
- 3
- 4
- 5
- 6
- 16













