str.upper() (全部大写)
str.lower() (全部小写)
str.startswith() (以什么开头)
str.endswith() (以什么结尾)
str.count() (统计)
str.replace() (替换) *****
str.strip() (除去头尾两边的空格) *****
str.lstrip() (去掉字符串左边的东西)
str.rstrip() (去掉字符串右边的东西)
str.split() (分割) *****
str.isdigit() (判断是不是阿拉伯数字)
str.isdecimal() (判断是不是十进制 -- 用它来判断是不是数字)
str.isalpha() (判断的是中文和字母)
str.isalnum() (判断的是不是字母,中文和阿拉伯数字)
str.isupper() (判断是大写字母)
str.islower() (判断是小写字母)
str.isdigit() (判断是数字)
format (第三种字符串格式化) 格式:str.format('结婚了',"要结婚了")
id (获取内存地址) 格式:print(id(name))
str.center() (把字符串居中) 格式:print(name.center(20,'-'))
str.capitalize() (字符串首字母大写)
str.find() (取得字符串中某个字符的下标,找不到元素时,不报错,返回-1)
str.isspace() (判断是否全都是空格)
str.zfill() (在字符串前面补0)

python之字符串str操作方法的更多相关文章

  1. python中字符串的操作方法

    python中字符串的操作方法大全 更新时间:2018年06月03日 10:08:51 作者:骏马金龙 我要评论这篇文章主要给大家介绍了关于python中字符串操作方法的相关资料,文中通过示例代码详细 ...

  2. 【转】Python格式化字符串str.format()

    原文地址:http://blog.xiayf.cn/2013/01/26/python-string-format/ 每次使用Python的格式字符串(string formatter),2.7及以上 ...

  3. python基础-字符串(str)类型及内置方法

    字符串-str 用途:多用于记录描述性的内容 定义方法: # 可用'','''''',"","""""" 都可以用于定义 ...

  4. python中字符串(str)常用操作总结

    # 字符串的常用操作方法 (都是形成新的字符串,与原字符串没有关系.) 1.字符串的基本操作之切片 s = 'python hello word' # 取首不取尾,取尾要+1 # 切片取出来的字符串与 ...

  5. python中字符串(str)的常用处理方法

    str='python String function' 生成字符串变量str='python String function' 字符串长度获取:len(str)例:print '%s length= ...

  6. python中的str.strip()的用法

    python中字符串str的strip()方法 str.strip()就是把字符串(str)的头和尾的空格,以及位于头尾的\n \t之类给删掉. 例1:str=" ABC"prin ...

  7. 【Python从入门到精通】(九)Python中字符串的各种骚操作你已经烂熟于心了么?

    您好,我是码农飞哥,感谢您阅读本文,欢迎一键三连哦. 本文将重点介绍Python字符串的各种常用方法,字符串是实际开发中经常用到的,所有熟练的掌握它的各种用法显得尤为重要. 干货满满,建议收藏,欢迎大 ...

  8. python 字符串常用操作方法

    python 字符串常用操作方法 python 字符串操作常用操作,如字符串的替换.删除.截取.赋值.连接.比较.查找.分割等 1.去除空格 str.strip():删除字符串两边的指定字符,括号的写 ...

  9. python字符串str

    字符串str常用操作方法(都会产生新的数据) 1.取值: (1)索引:s[0] (2)切片:s[起始索引:结束索引:步长] 起始索引为0,可以省略 s最后一个索引可以取-1 结束索引省略,默认取到最后 ...

随机推荐

  1. Know the Core Objects of Your App---了解应用程序的内核对象

    Back to App Design You develop apps using the Cocoa application environment. Cocoa presents the app’ ...

  2. https://www.luogu.org/blog/An-Amazing-Blog/mu-bi-wu-si-fan-yan-ji-ge-ji-miao-di-dong-xi

    https://www.luogu.org/blog/An-Amazing-Blog/mu-bi-wu-si-fan-yan-ji-ge-ji-miao-di-dong-xi

  3. 793. Preimage Size of Factorial Zeroes Function

    Let f(x) be the number of zeroes at the end of x!. (Recall that x! = 1 * 2 * 3 * ... * x, and by con ...

  4. poj 2774 Long Long Message【SA】

    把两个串接到一起求一个SA,然后找最大的sa[i]和sa[i-1]不是一个串的he[i] #include<iostream> #include<cstdio> #includ ...

  5. IT兄弟连 Java Web教程 Tomcat

    本文采用的Tomcat服务器版本是Tomcat8.5版本,Tomcat8.5支持Servlet3.1.JSP2.3以及EL3.0规范.并且Tomcat8.5版本对JDK8的支持比Tomcat8更加全面 ...

  6. try/except/finally

    Python也不例外,跟其他高级语言一样,内置了一套try...except...finally...的错误处理机制 当认为某些代码可能会出错时,就可以用try来运行这段代码 使用try时,要么exc ...

  7. 线段树(单点更新) HDOJ 4288 Coder

    题目传送门 #include <cstdio> #include <cstring> #define lson l, m, rt << 1 #define rson ...

  8. 1-18String类简介

    字符串(String)的不可变性 String类在java.lang包下面,是Object类的直接子类,通过API或者源码可以看到,String类是final修饰的,这说明String类不能被继承. ...

  9. 用python编写的excel拆分小工具

    from datetime import date,datetime from openpyxl import Workbook from openpyxl import load_workbook ...

  10. 增强的for循环