1. str

homepage

str.count(sub[, start[, end]])
str.encode(encoding="utf-8", errors="strict") str.format(*args, **kwargs) # s = "this is from {}".format(__file__)
str.find(sub[, start[, end]]) # 没有查找到子串,返回-1
str.rfind(sub[, start[, end]]) # 没有查找到子串,则报Except
str.index(sub[, start[, end]])
str.replace(old, new[, count]) str.join(iterable)
str.split(sep=None, maxsplit=-1)
str.splitlines([keepends]) # keepends: 在输出结果里是否保留换行符('\r', '\r\n', '\n'),默认为False,不包含换行符;如果为True,则保留换行符。
str.strip([chars])
str.lstrip([chars])
str.rstrip([chars])
str.partition(sep) # 通过sep将字符串分成三部分
str.rpartition(sep) In [85]: "what do you do wait".rpartition("do")
Out[85]: ('what do you ', 'do', ' wait') str.expandtabs(tabsize=8) # 把字符串中的 tab 符号('\t')转为空格
str.zfill(width) # 返回指定长度width的字符串,原字符串右对齐,前面填充0
str.upper()
str.lower() str.islower()
c.isalpha() # 字母
c.isdecimal() # Unicode数字,,全角数字(双字节)
c.isdigit() # Unicode数字,byte数字(单字节),全角数字(双字节),罗马数字
c.isnumeric() # Unicode数字,全角数字(双字节),罗马数字,汉字数字 str.startswith(prefix[, start[, end]])
str.endswith(suffix[, start[, end]]) eval(source[, globals[, locals]]) # 将str作为有效表达式并返回结果

2. bytes / bytearray

homepage

classmethod

  • fromhex(string)
  • encode()
bytes.count(sub[, start[, end]])
bytes.decode(encoding="utf-8", errors="strict")
bytearray.decode(encoding="utf-8", errors="strict") bytes.find(sub[, start[, end]])
bytearray.find(sub[, start[, end]])
bytes.join(iterable)
bytearray.join(iterable)
bytes.replace(old, new[, count])
bytearray.replace(old, new[, count])
bytes.startswith(prefix[, start[, end]])
bytearray.startswith(prefix[, start[, end]])

3. printf-style String Formatting

csdn: Python3字符串格式化

Python字符串处理 - str/bytes的更多相关文章

  1. Python字符串(Str)详解

    字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 创建字符串很简单,只要为变量分配一个值即可 字符串的格式 b = "hello itcast. ...

  2. (转)Python 字符串格式化 str.format 简介

    原文:https://www.cnblogs.com/wilber2013/p/4641616.html http://blog.konghy.cn/2016/11/25/python-str-for ...

  3. Python字符串(str)方法调用

    # str# n = 'pianYU'# v = n.capitalize() # 将字符串的首字母大写# print(v)## n = 'pianYI'# v1 = n.isupper() # 判断 ...

  4. python 字符串(str)和列表(list)的互相转换

    1.str to list  str1 = "12345"list1 = list(str1)print list1 str2 = "123 sjhid dhi" ...

  5. python 字符串编码 str和unicode 区别以及相互转化 decode('utf-8') encode('utf-8')

  6. python 字符串(str)

  7. Python 字符串基本操作

    字符串是Python的一种基本类型,字符串的操作包括字符串格式化输出.字符串的截取.合并,字符串的查找和替换等操作. 字符串定义 Python中有3种表示字符串的方法:单引号.双引号.三引号.引号使用 ...

  8. python字符串截取

    python字符串截取 str = 'abcd' str[0:-1],-1表示末尾开始的位置,但是[]操作符不取尾下标所对应的字符: 所以str[0:-1] ---->‘abc' str[0:1 ...

  9. Python入门篇-基础数据类型之整型(int),字符串(str),字节(bytes),列表(list)和切片(slice)

    Python入门篇-基础数据类型之整型(int),字符串(str),字节(bytes),列表(list)和切片(slice) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Py ...

随机推荐

  1. 《C程序设计语言》 练习3-5

    问题描述 练习 3-5 编写函数 itob(n, s, b),将整数n转换为以b为底的数,并将转换结果以字符的形式保存到字符串s中.例如,itob(n, s, 16)把整数n格式化成十六进制整数保存在 ...

  2. PG 更新统计信息

    http://blog.chinaunix.net/uid-24774106-id-3802225.html 一.vacuum的效果: 1.1释放,再利用 更新/删除的行所占据的磁盘空间. 第一点的原 ...

  3. mysql运维入门4:索引、慢查询、优化

    MySQL索引用来快速地寻找那些具有特定值的记录,所有MySQL索引都是以B-树的形式保存 如果没有索引,执行查询时,MySQL必须从第一个记录开始整表扫描,知道查询到符合要求的记录,记录越大,花费时 ...

  4. Apache Module mod_reqtimeout

    Apache Module mod_reqtimeout Available Languages: en Description: Set timeout and minimum data rate ...

  5. vue使用stylus样式预处理器

    vue使用stylus样式预处理器,样式总是报错,需要从上一行的样式回车换行才不会报错 <style lang="stylus" scoped> .navbar mar ...

  6. Elasticsearch SSL认证/证书制作

    制作目的 在上一篇<elasticsearch7.X x-pack破解>中,我们启用了x-pack模块,elasticsearch集群中,如果使用了x-pack,那么集群中的各节点之间通讯 ...

  7. SPL数据结构

    数据结构是计算机存储.组织数据的方式. SPL提供了双向链表.堆栈.队列.堆.降序堆.升序堆.优先级队列.定长数组.对象容器. 基本概念Bottom:节点,第一个节点称Bottom:Top:最后添加的 ...

  8. oracle表按日期分区创建、新增、修改、删除

    Oracle11G分区表 当表中的数据量不断增大,查询数据的速度就会变慢,应用程序的性能就会下降,这时就应该考虑对表进行分区.表进行分区后,逻辑上表仍然是一张完整的表,只是将表中的数据在物理上存放到多 ...

  9. 剑指Offer之跳台阶

    题目描述 一只青蛙一次可以跳上1级台阶,也可以跳上2级.求该青蛙跳上一个n级的台阶总共有多少种跳法(先后次序不同算不同的结果). 解法1:递归解法 public int JumpFloor(int t ...

  10. 小智的旅行(Bridge)51nod 提高组试题

    luogu AC传送门(官方数据) 题目描述 小智最喜欢旅行了,这次,小智来到了一个岛屿众多的地方,有N座岛屿,编号为0到N-1,岛屿之间 由一些桥连接,可以从桥的任意一端到另一端,由于岛屿可能比较大 ...