畅享聊:python切片及数据类型转换
off999 2024-09-13 13:36 113 浏览 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
审核|闫庆红
相关推荐
- pp视频在线观看免费大全下载
-
要下载ppvod网上的视频,可以使用第三方的视频下载工具,如迅雷、IDM等,或者使用在线视频下载网站,如savefrom.net、downvids.net等。在网站上输入视频的链接地址即可下载。同时,...
- 中国电信官方测网速(网络测速 中国电信)
-
1.下载并打开腾讯电脑管家,点击左下方的工具箱;2.打开工具箱后,点击“测试网速”功能;或者你也可以右键小火箭,选择网络优化/点击流量显示区域,进行检测;3.待测速网页弹出后,点击“一键测速”;4....
- 个人邮箱注册(163 邮箱注册个人邮箱注册)
-
步骤如下:(以网易163邮箱为例)1.打开网易邮箱网站mail.163.com,点击“立即注册”,进入注册画面。2.选择注册的方式,填写好相关资料,点击“立即注册”。3.回到之前的界面,填...
- 姑娘视频在线观看免费完整版高清
-
《82年生的金智英》是由金度英执导,郑裕美、孔刘主演的剧情电影,于2019年10月23日在韩国上映。该片改编自同名女性主义小说,讲述1982年出生的三十多岁平凡女性金智英,某一天突然觉得自己的言行变得...
- flash player播放器(flashplayer播放器在哪)
-
查询自己电脑上FlashPlayer的版本的方法如下:我们需要准备的材料分别是:电脑、控制面板app1、,首先打开电脑里的控制面板按钮。2、然后在控制面板的页面中找到FlashPlayer的插件...
- 英文翻译器在线转换(英语翻译器转换成汉语)
-
方法如下繁体字在线转换器工具就可以实现简体字和繁体字互相转换。在转换器文本框中输入繁体或简体汉字,然后点击“简转繁”或“繁转简”按钮就可以转换成对应的繁体字或简体字,转换结果显示在文本框中。转换结束后...
- 免费高清网络电视直播(免费网络电视台)
-
你下载一个卫星电视,里面有国外的一些频道找款好用的电视直播软件虽然不难,但是找款稳定又安全,长期维护且正版的,就很少了。但是最近在当贝市场里面竟然可以直接安装稳定又安全的电视直播软件,而且画质高清,还...
-
- 直接访问qq空间网址(直接访问qq空间网址是多少)
-
电脑访问qq空间的方法如下:1、首先双击鼠标右键打开电脑上的QQ软件,在弹出框里输入你的QQ账号和密码,然后点击下面的安全登录按钮。2、成功登陆QQ后,在QQ界面的上方找到“QQ空间”图标,如下图所指的图标,点击。3、就会跳转到QQ空间页面...
-
2026-02-02 06:51 off999
- 学生教育平台入口(学校学生教育平台登录)
-
灯塔系统学生端以以下方式进入1.PC端:图书馆主页—馆藏资源—试用资源—灯塔分级阅读(www.deltareading.com),点【学生入口】使用本人微信扫一扫登录。-登录后请在【班级】-【加入班级...
- 在线教育(在线教育龙头股有哪些)
-
学而思旗下有多个子品牌,如:学而思培优、智康一对一、学而思网校,还有学而思海边。学而思培优是指学而思的大班教学,根据年级不同,一个班的人数也不同,基本都是小学每班15人左右,初中20人左右,高中25人...
- 英语四级听力(英语四级听力多少分)
-
包括:1.短对话理解:主要涉及日常生活中的交际场景,如购物、问路、预订旅行、约会等。2.长对话理解:主要涉及社会生活和学习工作中的交际场景,如面试、工作会议、学术讲座、社交活动等。3.短文理解:...
- 免费高爆版传奇(超级变态版传奇10亿战力)
-
古云传奇高爆版是一款非常好玩的游戏。我认为它好玩的原因有以下几点:首先,游戏画面精美,场景设计非常细致,让人感觉身临其境。游戏中的人物形象也非常逼真,让人感觉非常舒适。其次,游戏玩法非常丰富,有很多不...
欢迎 你 发表评论:
- 一周热门
-
-
抖音上好看的小姐姐,Python给你都下载了
-
全网最简单易懂!495页Python漫画教程,高清PDF版免费下载
-
飞牛NAS部署TVGate Docker项目,实现内网一键转发、代理、jx
-
win7系统还原步骤图解(win7还原电脑系统的步骤)
-
Python 3.14 的 UUIDv6/v7/v8 上新,别再用 uuid4 () 啦!
-
python入门到脱坑 输入与输出—str()函数
-
16949认证费用是多少(16949审核员太难考了)
-
linux软件(linux软件图标)
-
Python三目运算基础与进阶_python三目运算符判断三个变量
-
(新版)Python 分布式爬虫与 JS 逆向进阶实战吾爱分享
-
- 最近发表
- 标签列表
-
- 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)
