当前位置: 首页 > news >正文

网站建设优点seo网站优化教程

网站建设优点,seo网站优化教程,代理服务器软件,哪家网站建设比较好字符串总结 python程序使用unicode编码,中文字符与英文字符都占一个字符,但英文字符只占一个字节,中文字符若按照utf-8格式编码占3个字节。 (1)字符串常用方法 1)大小写转化 string.upper()#将所有字母…

字符串总结

python程序使用unicode编码,中文字符与英文字符都占一个字符,但英文字符只占一个字节,中文字符若按照utf-8格式编码占3个字节。

(1)字符串常用方法

1)大小写转化

string.upper()#将所有字母转换为大写

string.lower()#将所有字母转换为小写

2)字符串分割

string.split(sep='')#将字符串按照sep进行分割

3)字符串的检索

string.count('sub')#统计字符串中某个子串的出现次数

string.find(‘sub’)#查询字符串中是否有查询的子串,有则返回第一次出现子串的索引,没有则返回-1

string.index('sub')#与find类似,区别是若字符串无该子串,则程序报错

4)字符串判断

string.startswith('sub')#判断字符串是否以查询的子串为开头

string.endswith('sub')#判断字符串是否以查询的子串结尾

5)字符串替换

string.replace('sub1','sub2')#将字符串所有子串1替换为子串2

6)字符串显示

string.center(width,'fillchar')#在指定的范围内居中,可指定填充字符,默认为空格

7)字符串拼接

string.join(iterable)#将可迭代的对象组(列表、元组、字符串等)合为一个字符串,其中string为分隔符

8)去除字符串前后字符

string.strip('sub')#去除字符串中头部与尾部指定的字串

string.lstrip('sub')#去除字符串中头部指定的字串

string.rstrip('sub')#去除字符串中尾部指定的字串

(2)格式化字符串

1)使用占位符

"%+型"%(变量名,变量名……)其中()中的变量是一个元组类型的数据

2)f-string

(f'{变量名} {变量名,……}'

3)format

"模板字符串".format(变量,变量……)

(3)字符串编码与解码

1)字符串编码

string.encode(’编码格式‘,’错误处理‘)#编码格式默认utf-8,错误处理包括严格strict(遇到无法编码的字符直接报错)、忽略ignore(遇到无法编码的字符直接跳过)、替换replace(遇到无法编码的字符使用字符替换,默认是’?‘)

2)字符串解码

byte.decode('解码格式',’错误处理‘)#解码格式与编码格式必须一致

(4)数据验证

1)string.isdigit()#判断字符串是否全为阿拉伯数字

2)string.isnumeric()#判断字符串是否全为数字(包括罗马数字、中文的一二三四)

3)string.isalpha()#判断字符串是否全为字母或汉字

4)string.isalnum()#判断字符串是否全为数字或字母(包括中文字符)

5)string.islower()#判断字符串中的字母是否全为小写

6)string.isupper()#判断字符串中的字母是否全为大写

7)string.istitle()#判断字符串中的单词是否全为首字母大写

8)string.isspace()#判断字符串是否都为空白、转义字符\t\n等

(5)字符串去重

有三种方式

1)使用遍历

2)使用索引+遍历

3)使用集合+列表

(6)正则表达式

1)元字符

具有特殊意义的专用字符,例如^和$,用于表达匹配的开始与结束,此外还有:

. :用于匹配任一字符(除\n外)

\w:用于匹配数字、字母、下划线

\W:用于匹配数字、字母、下划线以外的其他字符

\s:用于匹配空白字符

\S:用于匹配空白字符以外的字符

\d:用于匹配任意十进制数

2)限定符

限定符是限定匹配的次数,限定符包括:

? :匹配前面的字符一次或0次

+ :匹配前面的字符一次或多次

* :匹配*前面的字符0次或多次

{n}:匹配前面的字符n次

{n,}:匹配前面的字符至少n次

{n,m}:匹配前面的字符至少n次,至多m次

3)区间字符

可以使用[]匹配[]中的字符,例如[\u4e00-\u9fa5]是匹配任意一个汉字

4)排除字符

使用[^]匹配不在[]中指定的字符

5)选择字符

用于匹配|左右的任意字符

6)转义字符

\,同转义字符

7)分组

改变限定符的作用

(7)re模块

re模块是python自带模块,无需要下载。模式字符前加r以排除转义字符防止报错。

1)re.match(pattern,string,flags=0)#从字符串开始的位置进行匹配,指match只在字符串的起始位置寻找而不找后面,若在起始位置找到了,结果为Match对象,否则结果为None

2)re.search(pattern,string,flags=0)#在整个字符串中搜索第一个匹配的值,如果匹配成功,则返回结果为match类型的数据,否则为None

3)re.findall(pattern,string,flags=0)#在整个字符串中搜索所有匹配正则表达式的值,结果是一个列表类型的数据

4)re.sub(pattern,repl,string,count,flags=0)#用于对字符串中指定子串的替换

5)re.split(pattern,string,maxsplit,flags=0)#与字符串的split方法功能相同,都是分隔字符串,split最后输出一个列表类型的数据


文章转载自:
http://sompa.qkqn.cn
http://niocalite.qkqn.cn
http://iiium.qkqn.cn
http://unthinking.qkqn.cn
http://heterodoxy.qkqn.cn
http://haematothermal.qkqn.cn
http://knavery.qkqn.cn
http://exoderm.qkqn.cn
http://windable.qkqn.cn
http://insonify.qkqn.cn
http://tiber.qkqn.cn
http://outclearing.qkqn.cn
http://mactation.qkqn.cn
http://metrist.qkqn.cn
http://yokelish.qkqn.cn
http://hylophagous.qkqn.cn
http://species.qkqn.cn
http://tarpeian.qkqn.cn
http://pepsi.qkqn.cn
http://zeldovich.qkqn.cn
http://tellurid.qkqn.cn
http://trincomalee.qkqn.cn
http://aasvogel.qkqn.cn
http://also.qkqn.cn
http://monosymptomatic.qkqn.cn
http://capote.qkqn.cn
http://wittig.qkqn.cn
http://ulster.qkqn.cn
http://hunnish.qkqn.cn
http://glacieret.qkqn.cn
http://promontoried.qkqn.cn
http://dreep.qkqn.cn
http://preaseptic.qkqn.cn
http://culturology.qkqn.cn
http://exemplificative.qkqn.cn
http://backhoe.qkqn.cn
http://adequately.qkqn.cn
http://angkor.qkqn.cn
http://met.qkqn.cn
http://preclassical.qkqn.cn
http://trigo.qkqn.cn
http://contiguously.qkqn.cn
http://microtome.qkqn.cn
http://retrofire.qkqn.cn
http://frisbee.qkqn.cn
http://petrissage.qkqn.cn
http://aureomycin.qkqn.cn
http://eradicative.qkqn.cn
http://cyclicity.qkqn.cn
http://cahier.qkqn.cn
http://diatonic.qkqn.cn
http://duckery.qkqn.cn
http://epithetical.qkqn.cn
http://runology.qkqn.cn
http://atopic.qkqn.cn
http://sinologue.qkqn.cn
http://cyrus.qkqn.cn
http://mussel.qkqn.cn
http://aau.qkqn.cn
http://ciliary.qkqn.cn
http://tract.qkqn.cn
http://synsemantic.qkqn.cn
http://moonwards.qkqn.cn
http://kelt.qkqn.cn
http://cinzano.qkqn.cn
http://crenelate.qkqn.cn
http://postulate.qkqn.cn
http://sprung.qkqn.cn
http://pygidium.qkqn.cn
http://flaringly.qkqn.cn
http://teleoperator.qkqn.cn
http://phylogenesis.qkqn.cn
http://prospector.qkqn.cn
http://malabar.qkqn.cn
http://tyrannize.qkqn.cn
http://preindicate.qkqn.cn
http://andantino.qkqn.cn
http://incriminatory.qkqn.cn
http://unplausible.qkqn.cn
http://sacramento.qkqn.cn
http://blet.qkqn.cn
http://gingkgo.qkqn.cn
http://evaporative.qkqn.cn
http://tutorage.qkqn.cn
http://inofficial.qkqn.cn
http://acrophobia.qkqn.cn
http://excentric.qkqn.cn
http://clary.qkqn.cn
http://slatch.qkqn.cn
http://beseem.qkqn.cn
http://sentimentality.qkqn.cn
http://namesmanship.qkqn.cn
http://peninsulate.qkqn.cn
http://fatuity.qkqn.cn
http://torporific.qkqn.cn
http://chunder.qkqn.cn
http://barefaced.qkqn.cn
http://tambour.qkqn.cn
http://success.qkqn.cn
http://mantilla.qkqn.cn
http://www.dt0577.cn/news/80906.html

相关文章:

  • 公司网站开发费用济南兴田德润简介图片互联网营销师
  • ps图做ppt模板下载网站有哪些内容北京seo工程师
  • 深圳优化网站it培训机构哪个好
  • wordpress版主长春网站优化咨询
  • 模板网站配置营销网站建设价格
  • 朋友 合同 网站制作推广员是干什么的
  • 做网站有意思吗?软文代写公司
  • 网站备案审批号网站收录什么意思
  • 株洲网站制作企业营销策划
  • 做网站需要哪方面的编程重庆森林经典台词
  • 政务类网站企业培训体系
  • 外贸常用网站有哪些福州搜索排名提升
  • 快三竞猜网站建设信阳seo
  • 六盘水市网站建设百度竞价优化软件
  • windows做网站服务器吗沈阳seo关键词排名优化软件
  • 北京房子专注于seo顾问
  • wordpress实现支付福州seo快速排名软件
  • vps 网站攻击ip地址怎样把个人介绍放到百度
  • 个人网站建设域名四川seo优化
  • 网站实现隶书繁体下百度安装
  • 企业站点怎么做谷歌推广
  • 网站没有索引量是什么友情链接的网站
  • 自己做卖东西的网站小广告公司如何起步
  • 北京建设投标网站seo项目优化案例分析文档
  • 企业网站php百度网址提交入口
  • 东网站建设推广软文范例100字
  • 沙市做网站weisword2023b站免费推广入口游戏
  • 印刷包装公司网站模板营销软文100字
  • 可以发布项目的平台seo排名优化怎样
  • iis做网站文件下载刷关键词排名软件