# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#Python之str方法
#http://python.jobbole.com/82655/ #str为一个字符串,sub为str的一个子字符串。
#width为一个整数,用于说明新生成字符串的宽度。 #str.count(sub) 返回:sub在str中出现的次数
#str.find(sub) 返回:从左开始,查找sub在str中第一次出现的位置。如果str中不包含sub,返回 -1
#str.index(sub) 返回:从左开始,查找sub在str中第一次出现的位置。如果str中不包含sub,举出错误
#str.rfind(sub) 返回:从右开始,查找sub在str中第一次出现的位置。如果str中不包含sub,返回 -1
#str.rindex(sub) 返回:从右开始,查找sub在str中第一次出现的位置。如果str中不包含sub,举出错误 #str.isalnum() 返回:True, 如果所有的字符都是字母或数字
#str.isalpha() 返回:True,如果所有的字符都是字母
#str.isdigit() 返回:True,如果所有的字符都是数字
#str.istitle() 返回:True,如果所有的词的首字母都是大写
#str.isspace() 返回:True,如果所有的字符都是空格
#str.islower() 返回:True,如果所有的字符都是小写字母
#str.isupper() 返回:True,如果所有的字符都是大写字母 #str.split([sep, [max]]) 返回:从左开始,以空格为分割符(separator),将str分割为多个子字符串,总共分割max次。将所得的子字符串放在一个表中返回。可以str.split(‘,’)的方式使用逗号或者其它分割符
#str.rsplit([sep, [max]]) 返回:从右开始,以空格为分割符(separator),将str分割为多个子字符串,总共分割max次。将所得的子字符串放在一个表中返回。可以str.rsplit(‘,’)的方式使用逗号或者其它分割符 #str.join(s) 返回:将s中的元素,以str为分割符,合并成为一个字符串。
#str.strip([sub]) 返回:去掉字符串开头和结尾的空格。也可以提供参数sub,去掉位于字符串开头和结尾的sub
#str.replace(sub, new_sub) 返回:用一个新的字符串new_sub替换str中的sub
#str.capitalize() 返回:将str第一个字母大写
#str.lower() 返回:将str全部字母改为小写
#str.upper() 返回:将str全部字母改为大写
#str.swapcase() 返回:将str大写字母改为小写,小写改为大写
#str.title() 返回:将str的每个词(以空格分隔)的首字母大写 #str.center(width) 返回:长度为width的字符串,将原字符串放入该字符串中心,其它空余位置为空格。
#str.ljust(width) 返回:长度为width的字符串,将原字符串左对齐放入该字符串,其它空余位置为空格。
#str.rjust(width) 返回:长度为width的字符串,将原字符串右对齐放入该字符串,其它空余位置为空格。

Python之str方法的更多相关文章

  1. python的str,unicode对象的encode和decode方法

    python的str,unicode对象的encode和decode方法 python中的str对象其实就是"8-bit string" ,字节字符串,本质上类似java中的byt ...

  2. python str方法之ljust、rjust、center

    # -*- coding: cp936 -*- #python 27 #xiaodeng #str方法之ljust.rjust.center #http://www.runoob.com/python ...

  3. python的str,unicode对象的encode和decode方法(转)

    python的str,unicode对象的encode和decode方法(转) python的str,unicode对象的encode和decode方法 python中的str对象其实就是" ...

  4. python的str,unicode对象的encode和decode方法, Python中字符编码的总结和对比bytes和str

    python_2.x_unicode_to_str.py a = u"中文字符"; a.encode("GBK"); #打印: '\xd6\xd0\xce\xc ...

  5. Python 字典(Dictionary) str()方法

    Python 字典(Dictionary) str()方法 描述 Python 字典(Dictionary) str() 函数将值转化为适于人阅读的形式,以可打印的字符串表示.高佣联盟 www.cge ...

  6. python repr方法和str方法

    每个类都有默认的__repr__, __str__方法,用print 实例时调用类的str方法,直接输出类的实例,调用的是类的repr方法 在命令行界面,不用print命令打印而是直接写变量名,就是用 ...

  7. Python中sorted()方法

    Python中sorted()方法的用法 1.先说一下iterable,中文意思是迭代器. Python的帮助文档中对iterable的解释是:iteralbe指的是能够一次返回它的一个成员的对象.i ...

  8. python类及其方法

    python类及其方法 一.介绍 在 Python 中,面向对象编程主要有两个主题,就是类和类实例类与实例:类与实例相互关联着:类是对象的定义,而实例是"真正的实物",它存放了类中 ...

  9. python字符串replace()方法

    python字符串replace()方法 >>> help(str.replace)Help on method_descriptor:replace(...)    S.repla ...

随机推荐

  1. 25LINQ拾遗及实例

      投影 □ 遍历数组索引,Select获取 int[] indexes = {0, 2}; string[] strs = {"a", "b", " ...

  2. QDAC

    QDAC GITHUB: svn://www.qdac.cc/QDAC3 包括QMsgPack\QJson\QWoker...等序列和事件调度控件.

  3. android studio 引用aar

    在:libs拷贝对应的文件 build.gradle repositories {    flatDir {        dirs 'libs'    }}dependencies {   // c ...

  4. Ext.Toolbar.Fill()

    tbar : ['-',new Ext.form.Label({ text : '产品代码:' }),new Ext.form.TextField({ id : 'cpdm', name : 'cpd ...

  5. 基于Android的ELF PLT/GOT符号重定向过程及ELF Hook实现(by 低端码农 2014.10.27)

    引言 写这篇技术文的原因,主要有两个: 其一是发现网上大部分描写叙述PLT/GOT符号重定向过程的文章都是针对x86的.比方<Redirecting functions in shared EL ...

  6. 为apache安装mod_wsgi的时候出现-fpic的问题

    1.为了在apache里跑python项目,需要安装模块mod_wsgi 2.但是由于yum只支持python2.6,所以通过yum install mod_wsgi方式安装的mod_wsgi是pyt ...

  7. Cesium随笔(4)去掉cesium和bing地图的logo 【转】

    在开发过程中timeline上面的logo是不是有些碍眼嘞,下面写一下去掉的方法: 在style标签中添加 css: .cesium-widget-credits{   display:none!im ...

  8. Swap Nodes in Pairs leetcode java

    题目: Given a linked list, swap every two adjacent nodes and return its head. For example, Given 1-> ...

  9. Git 忽略规则 .gitignore文件 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  10. IE浏览器无法直接识别input的type="hidden"问题

    原问题: <td class="formValue" id="in-checkbox"> <label class="checkbo ...