On this page
  1. string.capwords
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

string.capwords

Up: string | Next: string.Formatter
Rel: string.Formatter, string.Template
Ref: docs.python.org — string.capwords
Tags: #public #python3 #stdlib #string


Import

import string
from string import capwords

Signature & Overview

string.capwords(s, sep=None)

Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None,

Usage

import string

assert string.capwords("they're  here") == "They're Here"

Gotchas

REPL Inspect

from string import capwords
help(capwords)

Linked from

Related notes