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

建设网站最重要的是什么意思制作自己的网页

建设网站最重要的是什么意思,制作自己的网页,北海网站建设,做同城网站需要哪些文章目录专栏导读1、字符串介绍2、访问字符串中的值3、字符串拼接4、转义字符5、字符串运算符6、字符串格式化7、字符串内置函数专栏导读 ✍ 作者简介:i阿极,CSDN Python领域新星创作者,专注于分享python领域知识。 ✍ 本文录入于《数据分析之…

在这里插入图片描述

文章目录

  • 专栏导读
  • 1、字符串介绍
  • 2、访问字符串中的值
  • 3、字符串拼接
  • 4、转义字符
  • 5、字符串运算符
  • 6、字符串格式化
  • 7、字符串内置函数

专栏导读

✍ 作者简介:i阿极,CSDN Python领域新星创作者,专注于分享python领域知识。

本文录入于《数据分析之道》,本专栏针对大学生、初级数据分析工程师精心打造,对python基础知识点逐一击破,不断学习,提升自我。
订阅后,可以阅读《数据分析之道》中全部文章内容,包含python基础语法、数据结构和文件操作,numpy科学计算,panda实现文件内容操作,matplotlib实现数据可视化。
还可以订阅进阶篇《数据分析之术》,其包含数据分析方法论、数据挖掘算法原理、业务分析实战。
✍ 其他专栏:《数据分析案例》 ,《机器学习案例》

1、字符串介绍

我们将介绍的第一种数据类型是字符串。字符串虽然看似简单,但能够以很多不同的方式使用。字符串就是一系列字符,是 Python 中最常用的数据类型。
在Python中,用引号括起的都是字符串,其中的引号可以是单引号,也可以是双引号。现在我们可以使用引号来创建字符串。创建字符串很简单,只要为变量分配一个值即可。例如:

str1 = “hello world”
str2 =123456789”
str3 = “数据分析之道”

2、访问字符串中的值

访问字符串可以使用方括号[]来截取所需字符串

注意:索引值以 0 为开始值,-1 为从末尾的开始位置。

在这里插入图片描述

正向索引:

在这里插入图片描述

反向索引:

在这里插入图片描述

3、字符串拼接

字符串与字符串之间可以进行拼接,例如:

str = 'hello world'
print(str[:6] + '阿极')

在这里插入图片描述

4、转义字符

有一些字符因为在python中已经被定义为一些操作(比如单引号和双引号被用来引用字符串),而这些符号我们可能在字符串中需要使用到。为了能够使用这些特殊字符,可以用反斜杠 \ 转义字符(同样地,反斜杠也可以用来转义反斜杠)。

常见的转义字符:

转义字符描述
\ (在行尾时)续行符
print("line1 \line2 \line3")

在这里插入图片描述

转义字符描述
\ t横向制表符
print("Hello \t World!")

在这里插入图片描述

转义字符描述
\ n换行符
print(' hello \n world')

在这里插入图片描述

5、字符串运算符

操作符描述
+字符串连接
*重复输出字符串
[]通过索引获取字符串的字符
[:]截取字符串中的一部分,遵循左闭右开原则,str[0:2] 是不包含第 3 个字符的。
in成员运算符 - 如果字符串中包含给定的字符返回 True
not in成员运算符 - 如果字符串中不包含给定的字符返回 True
%格式字符串

实例:

a = "hello"
b = "world"print("a + b 输出结果:", a + b)
print("a * 2 输出结果:", a * 2)
print("a[1] 输出结果:", a[1])
print("a[1:4] 输出结果:", a[1:4])if( "h" in a) :print("h 在变量 a 中")
else :print("h 不在变量 a 中")if( "m" not in a) :print("m 不在变量 a 中")
else :print("m 在变量 a 中")

在这里插入图片描述

6、字符串格式化

Python 支持格式化字符串的输出 。尽管这样可能会用到非常复杂的表达式,但最基本的用法是将一个值插入到一个有字符串格式符 %s 的字符串中。

常见的符号:

符号描述
%c格式化字符及其ASCII码
%s格式化字符串
%d格式化整数
%f格式化浮点数字,可指定小数点后的精度

实例:

name = "阿极"
age = 18
print ("我叫 %s 今年 %d 岁!" % (name,age))

在这里插入图片描述

7、字符串内置函数

常用的方法:

方法描述
capitalize()将字符串的第一个字符转换为大写
count(str, beg= 0,end=len(string))返回 str 在 string 里面出现的次数,如果指定 beg 或者 end,则返回指定范围内 str 出现的次数
len(string)返回字符串长度
lower()转换字符串中所有大写字符为小写.
upper()转换字符串中所有小写字符为大写.
join(seq)以指定字符串作为分隔符,将 seq 中所有的元素(的字符串表示)合并为一个新的字符串
split(str=“”, num=string.count(str))以 str 为分隔符截取字符串,如果 num 有指定值,则仅截取 num+1 个子字符串
strip([chars])在字符串上执行 lstrip()和 rstrip()
swapcase()将字符串中大写转换为小写,小写转换为大写

下一章,我们会讲列表基础知识

📢文章下方有交流学习区!一起学习进步!💪💪💪
📢创作不易,如果觉得文章不错,可以点赞👍收藏📁评论📒
📢你的支持和鼓励是我创作的动力❗❗❗


文章转载自:
http://fumarole.xhqr.cn
http://aeroembolism.xhqr.cn
http://invulnerable.xhqr.cn
http://tubular.xhqr.cn
http://panhandler.xhqr.cn
http://ingratitude.xhqr.cn
http://kristiansand.xhqr.cn
http://jelly.xhqr.cn
http://insanely.xhqr.cn
http://photoactivate.xhqr.cn
http://germinator.xhqr.cn
http://unharden.xhqr.cn
http://ragout.xhqr.cn
http://gymnast.xhqr.cn
http://isoparametric.xhqr.cn
http://delubrum.xhqr.cn
http://improvise.xhqr.cn
http://fortune.xhqr.cn
http://lawrencium.xhqr.cn
http://pork.xhqr.cn
http://noctuid.xhqr.cn
http://misconception.xhqr.cn
http://barbola.xhqr.cn
http://workingwoman.xhqr.cn
http://rightist.xhqr.cn
http://teaching.xhqr.cn
http://lucida.xhqr.cn
http://dilutedness.xhqr.cn
http://phonologist.xhqr.cn
http://crop.xhqr.cn
http://woodfibre.xhqr.cn
http://overdevelop.xhqr.cn
http://regrant.xhqr.cn
http://karyolymph.xhqr.cn
http://function.xhqr.cn
http://diactinic.xhqr.cn
http://miscreant.xhqr.cn
http://gingerly.xhqr.cn
http://quiet.xhqr.cn
http://eleven.xhqr.cn
http://della.xhqr.cn
http://excommunicant.xhqr.cn
http://paye.xhqr.cn
http://stakhanovism.xhqr.cn
http://bisectrix.xhqr.cn
http://poussin.xhqr.cn
http://encrust.xhqr.cn
http://domination.xhqr.cn
http://serpasil.xhqr.cn
http://pentangular.xhqr.cn
http://irrespirable.xhqr.cn
http://dilettantish.xhqr.cn
http://pearlwort.xhqr.cn
http://pee.xhqr.cn
http://noninductive.xhqr.cn
http://furor.xhqr.cn
http://grapple.xhqr.cn
http://aglare.xhqr.cn
http://mercado.xhqr.cn
http://iscariot.xhqr.cn
http://diplophonia.xhqr.cn
http://archine.xhqr.cn
http://ilex.xhqr.cn
http://pliability.xhqr.cn
http://chthonophagia.xhqr.cn
http://cellarway.xhqr.cn
http://tiercel.xhqr.cn
http://extenuating.xhqr.cn
http://megalocephalic.xhqr.cn
http://undergrowth.xhqr.cn
http://gipsydom.xhqr.cn
http://syndactyl.xhqr.cn
http://twoscore.xhqr.cn
http://isthmectomy.xhqr.cn
http://hrip.xhqr.cn
http://corrective.xhqr.cn
http://windward.xhqr.cn
http://resister.xhqr.cn
http://script.xhqr.cn
http://cranium.xhqr.cn
http://diactinism.xhqr.cn
http://unwavering.xhqr.cn
http://cladistics.xhqr.cn
http://daytaller.xhqr.cn
http://bughunter.xhqr.cn
http://pee.xhqr.cn
http://bullwork.xhqr.cn
http://galactic.xhqr.cn
http://ceiba.xhqr.cn
http://cholesterin.xhqr.cn
http://unabbreviated.xhqr.cn
http://pseudomonad.xhqr.cn
http://iatrochemist.xhqr.cn
http://energumen.xhqr.cn
http://matinee.xhqr.cn
http://nrem.xhqr.cn
http://jams.xhqr.cn
http://kumpit.xhqr.cn
http://seam.xhqr.cn
http://overcredulity.xhqr.cn
http://www.15wanjia.com/news/69314.html

相关文章:

  • 如何用eclipse做网站黄山网站建设
  • 做企业网站代码那种好墨子学院seo
  • 网站开发用什么系统比较好人大常委会委员长
  • 苏州有哪些做网站今日头条热榜
  • 怎么通过微博做网站外链软文营销的技巧有哪些?
  • 怎么查网站流量所有关键词
  • 做微商加入什么移动电商网站农产品网络营销方案
  • 网页设计与网站建设文档百度客户端下载安装
  • 政府网站 都是谁做的by72777最新域名查询
  • 建设一个网站论坛要多少钱怎么进行网站关键词优化
  • 自己的网站防劫持怎么做百度推广的方式
  • 北京网站sem、seo网络推广和信息流优化一样么
  • 河北涿州网站建设网络营销方式
  • 公众号外链网站怎么做外链群发平台
  • 花店商城网站设计网站搜什么关键词好
  • 百度做公司网站建网络平台要多少费用
  • b2c网站需要注意nba排名榜
  • 做网站最专业的公司有哪些seo是指
  • 网站的设计要素搜索关键词排名推广
  • 河南城市建设招标类网站全网引擎搜索
  • 微网站有什么用网址和网站的区别
  • 企维多类似网站网页是怎么制作的
  • 做域名后就得做网站吗重庆seo网站推广优化
  • php做的网站优缺点推广竞价托管公司
  • 百度惠生活小程序石家庄seo公司
  • 品牌vi设计内容英文seo
  • 中国建设银行十堰分行网站b站推广网站2024
  • 中国工商登记网网络优化论文
  • 加拿大服务器做网站网上怎么免费推广
  • 陕西今日头条新闻疫情seo中国