python下划线和驼峰互转
时间:2020-12-11 14:20:01
收藏:0
阅读:546
# -*- coding: UTF-8 -*- # python 3.9.0 64bit def hump2Underline(text): res = [] for index, char in enumerate(text): if char.isupper() and index != 0: res.append("_") res.append(char) return ‘‘.join(res).lower() def underline2Hump(text): arr = text.lower().split(‘_‘) res = [] for i in arr: res.append(i[0].upper() + i[1:]) return ‘‘.join(res)
原文:https://www.cnblogs.com/sinicheveen/p/14119910.html
评论(0)