转自http://wangwei007.blog.51cto.com/68019/1134323

# 一、pyhton字符串的大小写转换, 常用的有以下几种方法:

# 1、对字符串中所有字符(仅对字母有效)的大小写转换, 有两个方法:

print('just to test it'.upper())  # 所有字母都转换成大写  

print('JUST TO TEST IT'.lower())  # 所有字母都转换成小写  

# 2、对字符串中的字符(仅对字母有效)部分大小写转换:

print('JUST TO TEST IT'.capitalize())  # 字符串的首字母转换成大写, 其余转换成小写  

print('JUST TO TEST IT'.title())  # 字符串中所有单词的首字母转换成大写, 其余转换成小写  

# 二、判断字符串大小写函数:

print('JUST TO TEST IT'.isupper())
print('JUST TO TEST IT'.islower())
print('JUST TO TEST IT'.istitle())

python3 判断大小写的更多相关文章

  1. Python3 判断文件和文件夹是否存在、创建文件夹

    Python3 判断文件和文件夹是否存在.创建文件夹 python中对文件.文件夹的操作需要涉及到os模块和shutil模块. 创建文件: 1) os.mknod(“test.txt”) 创建空文件  ...

  2. Python3判断shell下进程是否存在&&启动&&邮件通知

    判断进程是否存在 def isRunning(process_name): try: process = len(os.popen('ps aux | grep "' + process_n ...

  3. python3判断字典、列表、元组为空以及字典是否存在某个key的方法

    #!/usr/bin/python3 #False,0,'',[],{},()都可以视为假 m1=[] m2={} m3=() m4={"name":1,"age&quo ...

  4. java 判断大小写、数字出现的次数

    //定义一个字符串 String s = "Hello123World"; //定义三个统计变量 int bigCount = 0; int smallCount = 0; int ...

  5. python3 判断数据类型

    def estType(): eventList = [1, 'Tom', {'name': 'Lucy', 'age': 16, 'grade': 98}] print(type(eventList ...

  6. python3 判断字符串是否为IP

    #!/usr/bin/python3 # -*- coding: utf-8 -*- import re ip = "192.168.1.1" ip = re.findall(&q ...

  7. iOS 中基础字符判断函数收集(如判断大小写、数字等)

    函数:isdigit 用法:#include 功能:判断字符c是否为数字 说明:当c为数字0-9时,返回非零值,否则返回零. 函数:islower 用法:#include 功能:判断字符c是否为小写英 ...

  8. python3 判断大小端的一种方法

    这里用到了array.array('H', [1])来测试大小端,[1]可以转化为十六进制的0x0001,占两位,00位高位, 01位低位,通过第一位就可以判断大小端. 如果是小端,则转化为bytes ...

  9. 用python3判断一个字符串 包含 中文

    在python中一个汉字算一个字符,一个英文字母算一个字符 用 ord() 函数判断单个字符的unicode编码是否大于255即可. s = '我xx们的88工作和生rr活168' n = 0 for ...

随机推荐

  1. Apache Ignite——集合分布式缓存、计算、存储的分布式框架

    Apache Ignite内存数据组织平台是一个高性能.集成化.混合式的企业级分布式架构解决方案,核心价值在于可以帮助我们实现分布式架构透明化,开发人员根本不知道分布式技术的存在,可以使分布式缓存.计 ...

  2. [LeetCode] Construct Binary Tree from Inorder and Pretorder Traversal

    Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that ...

  3. JSP-Runood:Eclipse JSP/Servlet 环境搭建

    ylbtech-JSP-Runood:Eclipse JSP/Servlet 环境搭建 1.返回顶部 1. Eclipse JSP/Servlet 环境搭建 本文假定你已安装了 JDK 环境,如未安装 ...

  4. Asp.Net 文件下载1——流下载(适用于大文件且防盗链)(转)

    使用流防盗链下载大文件 直接上 Asp.net 后置代码好了 using System; using System.Data; using System.Configuration; using Sy ...

  5. Same origin policy

    Chrome: Origin null is not allowed by Access-Control-Allow-Origin 的问题 发送 http request 时遇到 error: Ori ...

  6. 【weiphp】安装中报错

    问题描述:安装的第三部报错“SQLSTATE[HY000]: General error: 2030 This command is not supported in the prepared sta ...

  7. loadrunner中get和post请求

    loadrunner中可以使用web_url和web_link发送get请求,使web_submit_form和web_sumbit_data发送post请求. 有什么不同呢?推荐使用哪一个? web ...

  8. C# 写的正整数四则运算计算器

    实际上没能做出来负数.括号.小数的功能,才写这么个标题 大神直接略过,也欢迎指指点点-.- 输入一个四则运算表达式,计算出结果,想想不难,实现起来也不是很容易的. 流程:1.for循环输入的四则运算字 ...

  9. leetcode377 Combination Sum IV

    思路: dp. 实现: class Solution { public: int combinationSum4(vector<int>& nums, int target) { ...

  10. oracle 用sql语句管理数据库

    基础sql语句 创建数据库 :create database database_name; 创建表:create table(字段名 字段类型 字段为空约束 ,字段名 字段类型 字段为空约束,,,, ...