import re def to_camel_case(x): """转驼峰法命名""" return re.sub('_([a-zA-Z])', lambda m: (m.group(1).upper()), x) def to_upper_camel_case(x): """转大驼峰法命名""" s = re.sub('_([a-zA-Z])', lambda m: (m.group(1).upper()), x) return s[0].upper() + s[1:] def to_lower_camel_case(x): """转小驼峰法命名""" s = re.sub('_([a-zA-Z])', lambda m: (m.group(1).upper()), x) return s[0].lower() + s[1:]
标签:case,upper,return,sub,驼峰,python,re,字符串 From: https://www.cnblogs.com/navysummer/p/17368205.html