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. 干货分享:如何使用Kubernetes的Ingress API

    您可以通过使用诸如Kong for Kubernetes的Ingress控制器(使用自定义资源定义并提供许多插件)来极大地扩展Ingress资源的功能. Kubernetes正在整个技术行业中得到采用 ...

  2. PAT-1078 Hashing (散列表 二次探测法)

    1078. Hashing The task of this problem is simple: insert a sequence of distinct positive integers in ...

  3. vscode环境配置(三)——解决控制台终端中文输出乱码

    由于系统终端默认编码为GBK,所以需要修改为UTF-8 方法一 打开cmd输入chcp查看编码格式,查看以及修改如下图所示: 方法二

  4. Spring Boot在Docker上的部署

    一.准备工作 1.1 安装Docker环境 Docker 给旧版本的WIN系统提供的是Docker Toolbox下载(https://docs.docker.com/toolbox/overview ...

  5. Python3高级核心技术97讲

    可以毫不夸张的说:这门课程是初中级Python开发人员向高级进阶的必学课程 许多Pythoner喜欢追求新的框架,但却不重视Python本身基础知识的学习, 他们不知道的是,语言本身的进阶优先于框架, ...

  6. Dockerfile+Jenkinsfile+GitLab轻松实现.NetCore程序的CI&CD

    一.相关介绍 Dockerfile:关于Dockerfile的使用说明,我在文章<让.NetCore程序跑在任何有docker的地方>中有说到,这里不在赘述,需要的可以先看下,本文主要介绍 ...

  7. ## 0521Day04内部类

    [重点] Math公式 静态导入 正则表达式 内部类 访问修饰符 [Math] Math包的相关方法: round:四舍五入:-10.9==>-11/-11.2==>-11 floor:向 ...

  8. 使用PInvoke互操作,让C#和C++愉快的交互优势互补

    一:背景 1. 讲故事 如果你常翻看FCL的源码,你会发现这里面有不少方法借助了C/C++的力量让C#更快更强悍,如下所示: [DllImport("QCall", CharSet ...

  9. node_modules内容太大导致webstrom非常卡

    选中一个文件夹,例如node_modules,点击右键->mark directory as ->excluded,这样就可以把这个文件标记并排除出来,使webstorm不会扫描这个文件下 ...

  10. PAT1090 危险品装箱 (25分) ——值得留意的map用法(int型与vector型的关联)

    1090 危险品装箱 (25分)   集装箱运输货物时,我们必须特别小心,不能把不相容的货物装在一只箱子里.比如氧化剂绝对不能跟易燃液体同箱,否则很容易造成爆炸. 本题给定一张不相容物品的清单,需要你 ...