How to use capwords function for Python string

Capitalize all words in a string

capwords() capitalizes all words in a string.


import string

s = 'this is a test from java2s.com'
print string.capwords(s)

The code above generates the following result.





















Home »
  Python »
    Data Types »




Data Types
String
String Format
Tuple
List
Set
Dictionary