Python实现将不规范的英文名字首字母大写

yipeiwu_com5年前Python基础

例如

输入:['adam', 'LISA', 'barT'],输出:['Adam', 'Lisa', 'Bart']。

方法一

def wgw(x): 
  return [x[0].upper(),x[1:].lower()] 
 
map(wgw,['adam','LISA','barT']) 

方法二

def wgw1(x): 
  return x.capitalize() 
 
map(wgw1,['adam','LISA','barT']) 

方法三

map(lambda x:x.capitalize(),['adam','LISA','barT']) 

总结

以上就是Python实现将不规范英文名字首字母大写,其他小写的规范名字的全部内容,希望本文的内容对大家学习或者使用python能有所帮助,如果有疑问大家可以留言交流。

相关文章

使用TensorFlow实现SVM

使用TensorFlow实现SVM

较基础的SVM,后续会加上多分类以及高斯核,供大家参考。 Talk is cheap, show me the code import tensorflow as tf from s...

django使用django-apscheduler 实现定时任务的例子

下载: pip install apscheduler pip install django-apscheduler 将 django-apscheduler 加到项目中settings...

Python学习笔记(二)基础语法

学习Python,基本语法不是特别难,有了C的基本知识,理解比较容易。本文的主要内容是Python基础语法,学完后,能熟练使用就好。(开发环境依然是Python2.7,简单使用)一,基本...

django admin添加数据自动记录user到表中的实现方法

1.需求:在后台添加一条数据的同时要把添加者记录到表中。 2.models.py class Setting(models.Model): ... user =...

python中pass语句用法实例分析

本文实例讲述了python中pass语句用法。分享给大家供大家参考。具体分析如下: 1、空语句 do nothing 2、保证格式完整 3、保证语义完整 4、以if语句为例: C/C++...