数据库字段名批量转化为驼峰格式

import re
def camel(s):
    s = re.sub(r"(\s|_|-)+", " ", s).title().replace(" ", "")
    return s[0].lower() + s[1:]

# 批量转化
def batch_camel(slist):
    return [camel(s) for s in slist]




s = batch_camel(['student_id', 'student\tname', 'student-add'])
print(s)
# 结果
['studentId', 'studentName', 'studentAdd']

 

posted on 2020-03-31 15:38  不要挡着我晒太阳  阅读(1079)  评论(0编辑  收藏  举报

导航