str.title() fails with words containing apostrophes
Steve D'Aprano
steve+python at pearwood.info
Sun Mar 5 12:54:36 EST 2017
I'm trying to convert strings to Title Case, but getting ugly results if the
words contain an apostrophe:
py> 'hello world'.title() # okay
'Hello World'
py> "i can't be having with this".title() # not okay
"I Can'T Be Having With This"
Anyone have any suggestions for working around this?
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list