def to_camel_case(snake_str):
components = snake_str.split('_')
# We capitalize the first letter of each component except the first one
# with the 'title' method and join them together.
return components[0] + ''.join(x.title() for x in components[1:])
示例:
In [11]: to_camel_case('snake_case')
Out[11]: 'snakeCase'
下面是另一个take,它只适用于Python3.5及更高版本:
强制性一行:
示例:
相关问题 更多 >
编程相关推荐