0
点赞
收藏
分享

微信扫一扫

Python 下划线命名转换为 Java风格的命名

愚鱼看书说故事 2022-10-08 阅读 164


def underline_to_camel(underline_format):  
word_set = underline_format.split('_')
if len(word_set) == 1:
return underline_format

camel_format = ''
for i in range(len(word_set)):
if i == 0:
continue
word_set[i] = word_set[i].capitalize()
return ''.join(word_set)

print underline_to_camel(‘aaa’)
print underline_to_camel(‘aaa_bbb’)
print underline_to_camel(‘aaa_bbb_ccc’)


举报

相关推荐

0 条评论