feat: 初始化工程
This commit is contained in:
13
utils/common.py
Normal file
13
utils/common.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import re
|
||||
|
||||
|
||||
def camel_to_snake(name: str) -> str:
|
||||
"""将驼峰命名转换为蛇形命名(CamelCase → snake_case)"""
|
||||
name = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name)
|
||||
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', name).lower()
|
||||
|
||||
|
||||
def snake_to_camel(name: str) -> str:
|
||||
"""将蛇形命名转换为驼峰命名(snake_case → CamelCase)"""
|
||||
components = name.split('_')
|
||||
return ''.join(x.title() for x in components)
|
||||
Reference in New Issue
Block a user