首先,要明白Python swapcase() 方法用于对字符串的大小写字母进行转换。

其次,了解swapcase()方法语法:str.swapcase()

返回值:返回大小写字母转换后生成的新字符串。

实例

以下实例展示了swapcase()函数的使用方法:

#!/usr/bin/python
 
str = "hello python!!!";
print str.swapcase();
 
str = "HELLO WORLD!";
print str.swapcase();
 

以上实例输出结果如下:

HELLO PYTHON!!!

hello world!

Python swapcase()方法的更多相关文章

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

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

  2. python字符串方法的简单使用

    学习python字符串方法的使用,对书中列举的每种方法都做一个试用,将结果记录,方便以后查询. (1) s.capitalize() ;功能:返回字符串的的副本,并将首字母大写.使用如下: >& ...

  3. Python 字符串方法详解

    Python 字符串方法详解 本文最初发表于赖勇浩(恋花蝶)的博客(http://blog.csdn.net/lanphaday),如蒙转载,敬请保留全文完整,切勿去除本声明和作者信息.        ...

  4. Python str方法总结

    1.返回第一个字母大写 S.capitalize(...) S.capitalize() -> string 1 2 3 4 >>>a = 'shaw' >>> ...

  5. Python String 方法详解

    官网文档地址:https://docs.python.org/3/library/stdtypes.html#string-methods 官网 公号:软测小生ruancexiaosheng 文档里的 ...

  6. python 字符串方法整理

    Python字符串方法 1.大小写转换 1.1 lower.upper lower():小写 upper():大写 1.2 title.capitalize S.title():字符串中所有单词首字母 ...

  7. Python capitalize()方法

    Python capitalize()方法 capitalize()方法返回字符串的一个副本,只有它的第一个字母大写.对于8位的字符串,这个方法与语言环境相关. 语法 以下是capitalize()方 ...

  8. Python isdigit()方法

    描述 Python isdigit() 方法检测字符串是否只由数字组成. 语法 isdigit()方法语法: str.isdigit() 参数 无. 返回值 如果字符串只包含数字则返回 True 否则 ...

  9. Python list方法总结

    1. 向列表的尾部添加一个新的元素 append(...) L.append(object) -- append object to end 1 2 3 4 >>> a = ['sa ...

随机推荐

  1. C++各种进制的转换

    /* @author:CodingMengmeng @theme:各种进制之间的转换 @time:2017-1-6 21:39:08 @blog:http://www.cnblogs.com/codi ...

  2. Mysql Master-slave 主从配置

    MySQL主从复制 场景描述:主数据库服务器:192.168.10.130,MySQL已经安装,并且无应用数据.从数据库服务器:192.168.10.131,MySQL已经安装,并且无应用数据. 2. ...

  3. while用法一例

    package com.chongrui.test;/*while用法一例 * *///import java.util.Scanner;public class TypeConvertion { p ...

  4. Ajax:一种网页开发技术(Asynchronous Javascript + XML)

    创建新的 XMLHttpRequest 对象(Ajax 应用程序的核心): <script language="javascript" type="text/jav ...

  5. 剑指Offer-【面试题02:实现Singleton 模式——七种实现方式】

    题目:设计一个类,我们只能生成该类的一个实例 package com.cxz.demo02; /** * Created by CXZ on 2016/9/13. */ public class Si ...

  6. Selenium 简单的例子

    Selenium是一个web自动化验收测试框架.   Selenium Client Driver - Selenium 2.0 Document http://seleniumhq.github.i ...

  7. 配置比对脚本(python)

    # -*- coding: utf- -*- from datetime import * import MySQLdb import sys import time import datetime ...

  8. 让tomcat启动更快的设置

    http://wiki.apache.org/tomcat/HowTo/FasterStartUp#Entropy_Source 关于随机数的"熵源"(entropy source ...

  9. win7 下安装RVCT

    由于项目的需求,需要使用RVCT 3.1: 一看此包的发布日期,老的吓人,但没办法,只能硬着头皮安装: 环境:WIN7 安装软件RVCT 3.1 build 569 license:由于需要编译的代码 ...

  10. C# 利用 DbUp 通过多个SQL Script文件完成对数据库的更新

    详细流程请参考(本人测试过,很好用): http://dbup.github.io/ 配置截图: 程序如下: static int Main(string[] args) { var connecti ...