1. Home
  2. Computing & Technology
  3. Python

Functions of Python's String Module

By Al Lukaszewski, About.com

The following functions are available to operate on string and Unicode objects. They are not available as string methods.

  • capword(s): Splits the argument into words using split(), capitalize each word using capitalize(), and join the capitalized words using join(). Note that this functon replaces series of whitespace characters with a single space and removes both leading and trailing whitespace.
  • maketrans(from, to): Returns a translation table suitable for passing to [n]translate() or regex.compile(). Each character in from maps into the character at the same position in to; from and to must therefore have the same length.
Important: Don't use strings derived from lowercase and uppercase as arguments; in some locales, these don't have the same length. So, for case conversions, always use lower() and upper().

Explore Python

More from About.com

  1. Home
  2. Computing & Technology
  3. Python
  4. Python Library
  5. Python String Module - Functions for Python Strings

©2008 About.com, a part of The New York Times Company.

All rights reserved.