Install stringcase via pip
masterYou can install the stringcase library using pip:
$ pip install stringcaserepository·master·Indexed 42 days ago
https://github.com/okunishinishi/python-stringcaseA Python library for converting strings between various casing formats, including camelCase, snake_case, PascalCase, spinal-case, and more. It provides functions like `camelcase`, `snakecase`, `pascalcase`, and `alphanumcase` to handle both delimited and non-delimited input strings.
You can install the stringcase library using pip:
$ pip install stringcaseThe stringcase module provides functions to convert strings between various casing formats such as camelCase, PascalCase, snake_case, etc. Most functions are designed to handle both delimited (e.g., foo_bar) and non-delimited (e.g., FooBar) input strings by normalizing them to the target case.
Available conversion functions include:
camelcase: Converts to camelCase (e.g., fooBarBaz).capitalcase: Capitalizes the first letter (e.g., Foo_bar_baz).constcase: Converts to UPPER_SNAKE_CASE (e.g., FOO_BAR_BAZ).lowercase: Converts to lowercase (e.g., foobarbaz).pascalcase: Converts to PascalCase (e.g., FooBarBaz).pathcase: Converts to path format (e.g., foo/bar/baz).sentencecase: Converts to sentence case (e.g., Foo bar baz).snakecase: Converts to snake_case (e.g., foo_bar_baz).spinalcase: Converts to spinal-case (e.g., foo-bar-baz).titlecase: Converts to Title Case (e.g., Foo Bar Baz).trimcase: Trims delimiters while preserving case (e.g., FooBarBaz).uppercase: Converts to uppercase (e.g., FOOBARBAZ).alphanumcase: Removes non-alphanumeric characters and converts to a unified case (e.g., FooBar).import stringcase
stringcase.camelcase('foo_bar_baz') # => "fooBarBaz"
stringcase.pascalcase('foo_bar_baz') # => "FooBarBaz"
stringcase.snakecase('FooBarBaz') # => "foo_bar_baz"
stringcase.alphanumcase('_Foo., Bar') # => 'FooBar'