10 examples of 'python capitalize first letter of every word' in Python

Every line of 'python capitalize first letter of every word' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
50def _capitalizeWords(s):
51 w = WORD_RE.sub(_capitalizeMatch, s)
52 w = WORD2_RE.sub("", w)
53 return w
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

1085def _capitalize(s):
1086 return ' '.join(p.capitalize() for p in s.split())
255def capitalize_helper(string):
256 string_list = list(string)
257 string_list[0] = string_list[0].upper()
258 return "".join(string_list)
496def capitalize(s):
497 """capitalize(s) -> string
498
499 Return a copy of the string s with only its first character
500 capitalized.
501
502 """
503 return s.capitalize()
63def capitalize(s):
64 s = s.lower()
65 return s[0].upper() + s[1:]
178@naming_style
179def upper_camel_case(words):
180 return ''.join(upper_first_letter(word) for word in words)
264def capitalized(string):
265 return allcase(string[0]) + re.escape(string[1:])
155def camelcase(self, word):
156 """
157 Convert a string with underscores to a camel-cased one.
158
159 Ripped from https://stackoverflow.com/a/6425628
160 """
161 return ''.join(x.capitalize() or '_' for x in word.split('_'))
49def test_capitalize(self):
50 words = self.tokenizer.split(u"this is a test")
51 self.assertEquals(u"This is a test.", self.tokenizer.join(words))
52
53 words = self.tokenizer.split(u"A.B. Hal test test. will test")
54 self.assertEquals(u"A.b. Hal test test. Will test.",
55 self.tokenizer.join(words))
56
57 words = self.tokenizer.split(u"2nd place test")
58 self.assertEquals(u"2Nd place test.", self.tokenizer.join(words))
6def camelcase(chars):
7 words = WORD_PATTERN.split(chars)
8 return "".join(w.lower() if i is 0 else w.title() for i, w in enumerate(words))

Related snippets