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

yipeiwu_com7年前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能有所帮助,如果有疑问大家可以留言交流。

相关文章

Python常用模块介绍

python除了关键字(keywords)和内置的类型和函数(builtins),更多的功能是通过libraries(即modules)来提供的。 常用的libraries(module...

Python中输出ASCII大文字、艺术字、字符字小技巧

Python中输出ASCII大文字、艺术字、字符字小技巧

复制代码 代码如下: display text in large ASCII art fonts 显示大ASCII艺术字体 这种东西在源码声明或者软件初始化控制台打印时候很有用。...

pytorch 预训练层的使用方法

pytorch 预训练层的使用方法 将其他地方训练好的网络,用到新的网络里面 加载预训练网络 1.原先已经训练好一个网络 AutoEncoder_FC() 2.首先加载该网络,读取其存储...

Python实现的tab文件操作类分享

类代码: # -*- coding:gbk -*- import os class TABFILE: def __init__(self, filename, dest_fi...

python中print()函数的“,”与java中System.out.print()函数中的“+”功能详解

python中的print()函数和java中的System.out.print()函数都有着打印字符串的功能。 python中: print("hello,world!") 输出...