python中改变字母大小写的函数upper()和lower()

来源:互联网 发布:郑州seo公司hncxnet 编辑:程序博客网 时间:2024/06/04 19:56

今天学到map函数时写一个例子,看到了没接触过的upper函数

a = ‘hello’

a.upper()

print(a)==》‘HELLO’

自己写的例子如下:

# coding:utf-8def normalize(name):    return name[0].upper()+name[1:].lower()L1=['adam','LISA','barT']result=list(map(normalize,L1))print(result)

输出结果是:Adam Lisa Bart

原创粉丝点击