inflection is convenient
install
pip install inflection
import inflection as i
print("pluralize", i.pluralize("dog"))
print("singularize", i.singularize("dogs"))
# pluralize dogs
# singularize dog
When you want to create something like a class name from a plural table name
print(i.camelize(i.singularize("cats")))
# Cat
Recommended Posts