python3字符串
Python3 字符串
Python字符串运算符
|
+ |
字符串连接 |
a + b 输出结果: HelloPython |
|
* |
重复输出字符串 |
a*2 输出结果:HelloHello |
|
[] |
通过索引获取字符串中字符 |
a[1] 输出结果 e |
|
[ : ] |
截取字符串中的一部分,取到截止点的前一个 |
a[1:4] 输出结果 ell |
|
in |
成员运算符 - 如果字符串中包含给定的字符返回 True |
H in a 输出结果 1 |
|
not in |
成员运算符 - 如果字符串中不包含给定的字符返回 True |
M not in a 输出结果 1 |
|
r/R |
原始字符串 - 原始字符串:所有的字符串都是直接按照字面的意思来使用,没有转义特殊或不能打印的字符。 原始字符串除在字符串的第一个引号前加上字母"r"(可以大小写)以外,与普通字符串有着几乎完全相同的语法。 |
print r'\n' prints \n 和 print R'\n' prints \n |
|
% |
格式字符串 |
请看下一节内容。 |
|
[ : : ] |
以跳固定步数的方式,截取字符串中的一部分 |
a[0:6:2] 输出结果:Hlo |
Python 的字符串内建函数
|
1 |
capitalize() |
|
2 |
center(width, fillchar) |
|
3 |
count(str, beg= 0,end=len(string)) |
|
4 |
bytes.decode(encoding="utf-8", |
|
5 |
encode(encoding='UTF-8',errors='strict') |
|
6 |
endswith(suffix, beg=0, end=len(string)) |
|
7 |
expandtabs(tabsize=8) |
|
8 |
find(str, beg=0 end=len(string)) |
|
9 |
index(str, beg=0, end=len(string)) |
|
10 |
isalnum() |
|
11 |
isalpha() |
|
12 |
isdigit() |
|
13 |
islower() |
|
14 |
isnumeric() |
|
15 |
isspace() |
|
16 |
istitle() |
|
17 |
isupper() |
|
18 |
join(seq) |
|
19 |
len(string) |
|
20 |
ljust(width[, fillchar]) |
|
21 |
lower() |
|
22 |
lstrip() |
|
23 |
maketrans() |
|
24 |
max(str) |
|
25 |
min(str) |
|
26 |
replace(old, new [, max]) |
|
27 |
rfind(str, beg=0,end=len(string)) |
|
28 |
rindex( str, beg=0, end=len(string)) |
|
29 |
rjust(width,[, fillchar]) |
|
30 |
rstrip() |
|
31 |
split(str="", num=string.count(str)) |
|
32 |
splitlines([keepends]) |
|
33 |
startswith(str, beg=0,end=len(string)) |
|
34 |
strip([chars]) |
|
35 |
swapcase() |
|
36 |
title() |
|
37 |
translate(table, deletechars="") |
|
38 |
upper() |
|
39 |
zfill (width) |
|
40 |
isdecimal() |
python3字符串的更多相关文章
- [转]python3字符串与文本处理
转自:python3字符串与文本处理 阅读目录 1.针对任意多的分隔符拆分字符串 2.在字符串的开头或结尾处做文本匹配 3.利用shell通配符做字符串匹配 4.文本模式的匹配和查找 5.查找和替换文 ...
- python3字符串操作
python3字符串操作 x = 'abc' y = 'defgh' print(x + y) #x+y print(x * ) #x*n print(x[]) #x[i] print(y[:-]) ...
- 【2】python3字符串的比较(辨析is与==的区别)
PYTHON3基本数据类型(二.字符串) Python3字符串 ①字符串比较 1.比较字符串是否相同: ==:使用==来比较两个字符串内的value值是否相同 is:比较两个字符串的id值. 2.字符 ...
- python系列四:Python3字符串
#!/usr/bin/python #Python3 字符串#可以截取字符串的一部分并与其他字段拼接var1 = 'Hello World!'print ("已更新字符串 : ", ...
- python3 字符串属性(一)
python3 字符串属性 >>> a='hello world' >>> dir(a) ['__add__', '__class__', '__contains_ ...
- (十四)Python3 字符串格式化
Python3 字符串格式化 字符串的格式化方法分为两种,分别为占位符(%)和format方式.占位符方式在Python2.x中用的比较广泛,随着Python3.x的使用越来越广,format方式使用 ...
- Python3字符串 详解
Python3 字符串 字符串是 Python 中最常用的数据类型.我们可以使用引号('或")来创建字符串. 创建字符串很简单,只要为变量分配一个值即可. Python 访问字符串中的值 P ...
- [No000078]Python3 字符串操作
#!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Python 字符串操作 string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分 ...
- python3 字符串操作相关函数
整理自python基础|菜鸟教程 感谢菜鸟教程提供的优质资源! 1.capitalize() 将字符串的第一个字符转换为大写 实例 以下实例展示了capitalize()方法的实例: #!/usr/b ...
随机推荐
- 人生第一个过万 Star 的 github 项目诞生
写 Spring Boot 开源项目走入第三个年头,终于有一个开源项目要破万 Star 了,请各位读者大人批评指正. Spring Boot 文章 2016年,我开始学习 Spring Boot 的时 ...
- 使用jsp,tag提取字符串中的单词
JSP中调用Tag在表单中输入字符串,提取其中的单词 参考代码:giveString.jsp <%@ page contentType="text/html; charset=GB23 ...
- 查看dll或lib中包含的函数
这个功能主要用于检测是否包含自己所需的函数,可能在解决 error LNK2019 时会用到. dumpbin /exports avcodec.lib /out:test.txt
- Spring Boot 集成Swagger
Spring Boot 集成Swagger - 小单的博客专栏 - CSDN博客https://blog.csdn.net/catoop/article/details/50668896 Spring ...
- git submoudle提交
进入到各个submoudle文件夹 git status 查看所在branch和文件修改状态 git add [files]; git commit "" git pull ori ...
- React react-fastclick-alt 移动端点击
1. Install npm install --save-dev react-fastclick-alt 2. 用法 将元素或者component放在 <FastClick>...&l ...
- Consecutive Sum LightOJ - 1269(区间异或和)
Consecutive Sum 又来水一发blog... 本来是昨天补codechef的题,最后一道题是可持久化字典树,然后去黄学长博客看了看 觉得字典树写法有点不太一样,就想着用黄学长的板子写码几道 ...
- elastic的gc相关
https://www.jianshu.com/p/1f450826f62e gc原理介绍 相关优化 https://zhaoyanblog.com/archives/319.html 问题 ht ...
- EXCEL计算根据当前时间和身份证号计算准确年龄
假设身份证号在A2单元格 =IF(MONTH(NOW())<MONTH(DATE(MID(A2,7,4),MID(A2,11,2),MID(A2,13,2))),INT(YEAR(NOW())- ...
- 「洛谷3338」「ZJOI2014」力【FFT】
题目链接 [BZOJ] [洛谷] 题解 首先我们需要对这个式子进行化简,否则对着这么大一坨东西只能暴力... \[F_i=\sum_{j<i} \frac{q_iq_j}{(i-j)^2}-\s ...