首页 > 编程语言 > 详细

Python 字符串大小写操作

时间:2015-01-01 17:17:34      阅读:309      评论:0      收藏:0      [点我收藏+]
#coding=utf-8
#python中字符串的操作
#  字符串的大小写
s=‘hello_wOrld_oF_you‘
upper_str = s.upper() 
print(‘全部大写: ‘,upper_str)
lower_str = s.lower()
print(‘全部小写: ‘,lower_str)
Capitallize_str = s.capitalize()
print(‘大写首字母: ‘,Capitallize_str)
title_str=s.title()
print(‘标题似大写:‘,title_str)
up_str1=s[0].upper()+s[1:].lower()
print(‘只大写某个字母: ‘,up_str1)

# 字符串分割
split_str=s.split(‘_‘,2)
print(‘把对象按照提示的符号进行提示次数的分割: ‘,split_str)
sub_str=‘,‘.join(s.split(‘_‘))
print(‘把对象按照提示的符号进行分割,并按照与新字符连接: ‘,sub_str)
b=s.join(‘abc‘)
print (b)

部分内容参考至网络,更详细使用请参考:

http://www.cnblogs.com/SunWentao/archive/2008/06/19/1225690.html

Python 字符串大小写操作

原文:http://www.cnblogs.com/lizhaoxian/p/4197327.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!