代码如下
2021-04-16补充一种实现方式
# -*- coding: utf-8 -*-
import redef pascal_case_to_snake_case(camel_case: str):
"""大驼峰(帕斯卡)转蛇形"""
snake_case = re.sub(r"(?P<key>[A-Z])", r"_\g<key>", camel_case)
return snake_case.lower().strip('_')
def snake_case_to_pascal_case(snake_case: str):
"""蛇形转大驼峰(帕斯卡)"""
words = snake_case.split('_')
return ''.join(word.title() for word in words)
</div>