#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 字符串大小写操作的更多相关文章

  1. Python字符串切片操作知识详解

    Python字符串切片操作知识详解 这篇文章主要介绍了Python中字符串切片操作 的相关资料,需要的朋友可以参考下 一:取字符串中第几个字符 print "Hello"[0] 表 ...

  2. python 字符串 大小写转换 以及一系列字符串操作技巧

    总结 capitalize() 首字母大写,其余全部小写 upper() 全转换成大写 lower() 全转换成小写 title() 标题首字大写,如"i love python" ...

  3. python字符串的操作(去掉空格strip(),切片,查找,连接join(),分割split(),转换首字母大写, 转换字母大小写...)

    #可变变量:list, 字典#不可变变量:元祖,字符串字符串的操作(去掉空格, 切片, 查找, 连接, 分割, 转换首字母大写, 转换字母大小写, 判断是否是数字字母, 成员运算符(in / not ...

  4. Python字符串的操作

    字符串常用操作 name = "my name is alex" # 注: python中方法名前后带下划线的是供内部使用的方法, 如方法__dir__(). 这种方法是不对外提供 ...

  5. day7 python字符串的操作及方法

    1.字符串 1.1 字符串的操作 # 1.字符串的拼接 strvar = "我爱" + "中国" # 2.字符串的重复 strvar = "今天下午2 ...

  6. python 字符串 大小写转换

    总结 capitalize() 首字母大写,其余全部小写 upper() 全转换成大写 lower() 全转换成小写 title() 标题首字大写,如"i love python" ...

  7. Python—字符串的操作

    字符串的操作 变量: 变量只能是 字母,数字或下划线的任意组合,但首个字符不能为数字,且不能有空格 以下关键字不能声明为变量: and ,as, assert, break ,class ,conti ...

  8. 【转】Python 字符串大小写转换

    转载自:python 中字符串大小写转换 一.pyhton字符串的大小写转换, 常用的有以下几种方法: 1.对字符串中所有字符(仅对字母有效)的大小写转换,有两个方法: print 'just to ...

  9. python 字符串大小写转换(不能使用swapcase()方法)

    python 3字符串大小写转换 要求不能使用swapcase()方法 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wa ...

随机推荐

  1. Updates were rejected because the remote contains work that you do(git报错解决方案)

    Updates were rejected because the remote contains work that you do(git报错解决方案) 今天向GitHub远程仓库提交本地项目文件时 ...

  2. opencv提供的带参数例程

    body { font-family: @微软雅黑; font-size: 8pt; line-height: 1.5 } html,body { color: inherit; background ...

  3. js 的数学处理方法

    1.javascript取整方法floor.round.ceil floor向下取整: Math.floor(0.20); Math.floor(0.90); Math.floor(-0.90); / ...

  4. 浅谈Android的广告欢迎界面(倒计时)

    前些时候就是别人问我他的android APP怎么做一个广告的欢迎界面,就是过几秒后自动跳转到主界面的实现. 也就是下面这种类似的效果.要插什么广告的话你就换张图吧. 那么我就思考了下,就用了andr ...

  5. python批量处理

    # -*- coding: utf-8 -*- """ Created on Sat Jun 20 19:36:34 2015 @author: chaofn " ...

  6. jQuery判断Dom对象是否存在

    我们时常要检测一个DOM对象是否为空. var $jObject = $('#btn'); alert($jObject ); 我们会发现,$jObject 永远不会为空.为什么呢?$ 方法查找对象, ...

  7. 信息学奥赛一本通算法(C++版)基础算法:高精度计算

    高精度加法(大位相加) #include <bits/stdc++.h> using namespace std; int main() { ],b1[]; ],b[],c[];//a,b ...

  8. 基于Windows下python环境变量配置

    方法和Java环境变量配置是一样的,不懂的请移步这里 虽然这样说,还是唠唠叨叨几句吧QAQ 默认情况下,在windows下安装python之后,系统并不会自动添加相应的环境变量.此时不能在命令行直接使 ...

  9. HDU 2037 今年暑假不AC(贪心,区间更新,板子题)

    今年暑假不AC Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  10. hdu_1012(水题。。。不能再水)

    #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using ...