畅享聊:python切片及数据类型转换
off999 2024-09-13 13:36 103 浏览 0 评论
分享兴趣,传播快乐,增长见闻,留下美好!
亲爱的您,这里是LearningYard新学苑。今天小编为你带来
畅享聊:Python序列切片及数据类型转换
欢迎您的访问!
Share interests, spread happiness, increase knowledge, and leave beautiful!
Dear you, this is LearningYard Academy.
Today, the editor brings you
Enjoy chatting: Python sequence slicing and data type conversion
welcome your visit!
Python的世界真丰富,今天小编带给大家的是关于Python序列的一些知识与操作。切片操作,先看看语法结构:
序列[start:end:step]
简单说明:
1.start表示切片的开始位置(包括开始位置),若不指定则默认为0
2.end表示结束为止(不包括结束位置),若不指定则默认为序列长度
3.step表示步长,若不指定则默认为1
整体如图
The world of Python is really rich. Today's small compilation brings you some knowledge and operations about Python sequences. For slicing, first look at the syntax structure:
Sequence [start: end: step]
Brief description:
1. Start indicates the starting position of the slice (including the starting position). If not specified, it defaults to 0
2. End indicates the end (excluding the end position). If not specified, it defaults to the sequence length
3. Step represents step size. If not specified, it defaults to 1
As shown in the figure
★
下面的这张图能够帮助理解“步长”(ps:#表示注销该部分)
The following figure can help to understand the "step size" (ps: # means to log off this part)
序列的加法与乘法:
Addition and multiplication of sequences:
这是一些序列相关的操作符和函数:
Here are some sequence related operators and functions:
看到这些多少有点心痒痒,毕竟动手实践是编程的乐趣所在嘛,这也有助于熟悉掌握。ps:w=’Hellowworld’
It's a bit itchy to see these. After all, hands-on practice is the fun of programming, which is also conducive to familiarity and mastery. ps:w=’Hellowworld’
大家可以发现,输出w的最大值是“w”,输出的最小值“d”。于是就很疑惑了,为什么会是这俩字母呢,其实每个字母都对应着一个Unicode码。这就是根据Unicode码来排的大小。
下面这些是一些基础的Python Number类型转换:
1.int(x[,base])将x转化为一个整数
2.long(x[,base])将x转化为一个长整数
3.float(x)将x转化为一个浮点数
4.str(x)将x转化为一个字符串
5.repr(x)将x转化为表达式字符串
6.eval(str)用来计算字符串中的有效python表达式,并返回一个对象
7.tuples(s)将序列s转化为一个元组
8.list(s)将序列s转化为一个列表
9.chr(x)将一个整数转化为一个字符
10.unichr(x)将一个整数转化为一个Unicode字符
11.ord(x)将一个字符转化为它的整数值
12.hex(x)将一个整数转化为一个十六进制的字符串
13.oct(x)讲一个整数转化为一个八进制的字符串
You can find that the maximum value of output w is "w" and the minimum value of output is "d". Then I was very confused. Why are these two letters? In fact, each letter corresponds to a Unicode code. This is the size according to the Unicode code.
The following are some basic Python Number type conversions:
1. int (x [, base]) converts x to an integer
2. long (x [, base]) converts x to a long integer
3. float (x) converts x to a floating point number
4. str (x) Converts x to a string
5. repr (x) Converts x to an expression string
6. eval (str) is used to calculate the valid python expression in the string and return an object
7. tuples (s) convert sequence s into a tuple
8. list (s) Converts sequence s into a list
9. chr (x) Converts an integer to a character
10. unichr (x) Converts an integer to a Unicode character
11. ord (x) Converts a character to its integer value
12. hex (x) Converts an integer to a hexadecimal string
13. oct (x) is used to convert an integer into an octal string
今天的分享就到这里了。
如果您对今天的文章有独特的想法,
欢迎给我们留言,
让我们相约明天,
祝您今天过得开心快乐!
That's it for today's sharing.
If you have a unique idea about today’s article,
Welcome to leave us a message,
Let us meet tomorrow,
I wish you a happy day today!
本文由learningyard新学苑原创,如有侵权,请联系我们。
参考资料:b站视频,菜鸟教程
部分图片来源:b站视频截图
翻译来源:百度翻译
文字&排版|calm
审核|闫庆红
相关推荐
-
- pubg官网入口(pubg国际服手游下载)
-
pubg手游官网进入方法如下:1、地址:www.pubgmobile.com/en-US/home.shtml复制左边的地址粘贴到浏览器打开即可。2、进入pubgmobile国际服官网后,可以点击右上角的地球按钮选择中文字样,这样页面的字...
-
2026-01-20 19:15 off999
- 百度官方下载(百度官方下载安装免费)
-
1.打开应用商店:首先,找到并打开手机自带的应用商店,进入主页。2.搜索栏下载:在搜索栏里搜索你要下载的APP的名称,进行搜索,然后在弾出的搜索结果界面里,点击右方的“下载”选项。3.“分类”下载:在...
- 财达证券大智慧手机版官方下载
-
可以采取以下几个方法解决:1、通过拨打券商客服电话,通过短信发送账号;2、去券商网点柜台查询;3、通过券商微信公众号或官网进行查询。股东账户即证券账户,证券账户是指证券登记结算机构为投资者设立的,用...
- 英语四级听力音频(英语四级听力音频mp3)
-
1/4首先点击耳机开关,打开听力耳机。先打开耳机电源,一般每个按键都有对应的文字或者按钮标识的,开关键都是通用的标识。?2/4点击听力耳机的调频键,增加频率是“+键”,减少频率是“-键”。?3/4点击...
- 欧洲卡车模拟(欧洲卡车模拟2mod)
-
欧洲卡车模拟中,要打开右转灯,可以按键盘上的“/”键或者“*”键。这两个键都可以用来控制车辆的转向灯。具体操作方法可能因游戏版本和操作系统而异,建议根据游戏指南或游戏说明进行操作。游戏设置里可以自己修...
- 一起作业(一起作业听力材料制作入口)
-
一起作业国家让用,一起作业APP是一款学生学习和老师教学于一体的作业布置软件,里边可以布置学生的作业,学生可以在家里做作业,一起作业自动给你打分,判断对错,是一款比较好的学生,做题的软件,一起作业,...
- h5游戏源码买卖平台(h5游戏源码论坛)
-
1可以通过开发者工具查看游戏源码。2开发者工具是浏览器内置的一种开发者辅助工具,可以查看网页的HTML、CSS、JavaScript以及网络请求等信息。在浏览器中打开游戏页面后,可以按下F12键或...
- 好用的磁力链接引擎(2020最好用的磁力连接)
-
01.磁力熊磁力熊,是一个内容丰富、功能最为强大的一个磁力搜索网站,通过它不仅仅可以搜索到大量纯净的1080P高分电影,像一些比较小众的影视剧这里也都能找到。02.夕阳小站夕阳小站,虽然网站整体界面设...
- 适合夫妻的suv(夫妻免费观看完整版电视剧)
-
新婚夫妻最好选择空间较大、安全性好、经济实用的SUV。以下是一些适合新婚夫妻的SUV:1.丰田RAV4:这是一款经典的SUV,它拥有可靠的品牌、宽敞的内部空间、高效的油耗和各种安全性能。2.本田CR-...
- 成人版哔哩哔哩bilibili(成人版哔哩哔哩在线看)
-
1.对于成年人来说,需要在bilibili官网上进行注册。在注册页面中,需要填写邮箱、密码和验证码。同时需要同意网站的用户协议和隐私政策。2.在填写个人信息时,需要提供真实的姓名、性别、出生日期等...
- 安卓手机杀毒软件官方免费下载
-
安全的。一只猫影视大全app是一款能够帮助你们一起找到电影电视剧资源的软件,这个版本是安全免费的,大家可以放心下载,每天都会有最新电影电视剧推荐,还有各种好看有趣的综艺,首页没有的资源大家也可以通过搜...
- 美图秀秀官方免费下载(美图秀秀新版免费下载)
-
因为注册了才能够使用,才能够实名认证,接收手机验证码。可以为以后充值甚至是实名制避免出现违法行为而做准备。不行,美图秀秀的下载是属于个人意愿的 美图秀秀针对PC端仅有windows版,没有针对苹果自带...
-
- 翻译中文(翻译中文成英文的软件)
-
1.下载安装迅捷PDF转换器,找到操作页面中的“特色转换”点击其中的“Word翻译”2.后点击页面中的“添加文件”或者“点击或拖拽文件添加”,添加需要翻译的文件。3.添加完成文件添加之后,点击页面中的文字选择,选择“简体中文”再点“英文”就...
-
2026-01-20 15:51 off999
欢迎 你 发表评论:
- 一周热门
- 最近发表
- 标签列表
-
- python计时 (73)
- python安装路径 (56)
- python类型转换 (93)
- python进度条 (67)
- python吧 (67)
- python的for循环 (65)
- python格式化字符串 (61)
- python静态方法 (57)
- python列表切片 (59)
- python面向对象编程 (60)
- python 代码加密 (65)
- python串口编程 (77)
- python封装 (57)
- python写入txt (66)
- python读取文件夹下所有文件 (59)
- python操作mysql数据库 (66)
- python获取列表的长度 (64)
- python接口 (63)
- python调用函数 (57)
- python多态 (60)
- python匿名函数 (59)
- python打印九九乘法表 (65)
- python赋值 (62)
- python异常 (69)
- python元祖 (57)
