# -*- coding:utf-8 -*- import string myStr1="hello,world" myStr2="您好,世界" print myStr1 print myStr2 print "==========" print string.capwords(myStr1) transTable=string.maketrans('elo您','ELO你') print myStr1.translate(transTable) print myStr2.translate(transTable)
转换表和首字母大小
$ python ~/Documents/pylearn/learn1.py
hello,world
您好,世界
==========
Hello,world
hELLO,wOrLd
你好,世界