驼峰转下划线 小写代码块
时间: 2023-05-13 12:06:54 浏览: 88
代码块格式-python os模块实例详解
以下是将驼峰命名法转换为下划线命名法的小写代码块:
```python
def camel_to_snake(camel_case):
snake_case = ''
for i in range(len(camel_case)):
if camel_case[i].isupper():
snake_case += '_' + camel_case[i].lower()
else:
snake_case += camel_case[i]
return snake_case
camel_case = '驼峰转下划线'
snake_case = camel_to_snake(camel_case)
print(snake_case)
```
输出结果为:`驼峰转下划线` 转换为 `驼峰转下划线`
阅读全文