畅享聊:python切片及数据类型转换
off999 2024-09-13 13:36 71 浏览 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
审核|闫庆红
相关推荐
- 番茄花园ghost系统(番茄花园u盘重装系统win7)
-
首先,将GhostXPSP3镜像文件解压缩到一个新的文件夹中。然后,使用Ghost软件将镜像文件写入U盘或刻录成光盘。接下来,将电脑设置为从U盘或光盘启动。在Ghost界面中,选择“一键还原”或“...
- 爱奇艺免费版下载安装(爱奇艺免费版下载安装手机)
-
这个是不能确定的想观看爱奇艺的所有内容的视频呢,你必须开通一个会员,比如说开通一星期的或者一个月的,或者一年的,这样的话里面的VIP影视你也可以观看,免费的也可以但是如果你不开通会员的话,只能观看爱奇...
- microsoft office powerpoint下载
-
如果你想下载一个ppt软件,那么你需要下载(破解版)的MicrosoftOffice套件,随便2003,2007,2010那个版本的套件都行。套件安装过程中可以选择安装MicrosoftOfficeP...
- windows11 官方下载(windows 11正式版下载)
-
WIN11还没有正式发布,所以还没有下载官网。方法/步骤分步:1打开软件选择商店,点击搜索栏。2搜索栏内输入游戏名称,点击搜索。3搜索结果下点击进入游戏详情界面。4点击立即下载。5选择并设置下载路径和...
- 水星路由器登陆密码(水星无线路由器登陆密码)
-
一般水星无线路由器的初始用户名和密码都是admin如果无线路由器的密码修改过,忘记的话,可用大头针轻轻地戳一下无线路由器上的Reset键恢复出厂设置,然后按照路由器后面的用户名及密码进入设置。水星路...
- win7的安装步骤(我告诉你win7怎么安装)
-
安装方法:1、先下载好win7官方原版iso镜像,放在c盘以外的磁盘。2、找到下载好的iso镜像,直接双击打开,win10自带有ISO文件读取的软件,不需下载其他解压软件。3、最好将压缩包解压出来,放...
-
- 联想笔记本wifi开关在哪里(联想笔记本wi-fi开关)
-
方法/步骤1、打开电脑,进入桌面,按住键盘上的windows键(空格键左边alt旁边的图标)+X。2、进入windows移动中心,点击无线网络下的“打开无线”即可。3、也可以,右击任务栏右下角的“无线”图标,点击“打开网络共享中心”。4、进...
-
2025-12-14 07:03 off999
- 虚拟机安装kali教程(虚拟机安装kali linux教程)
-
步骤如下:1.下载KaliLinuxISO镜像文件,并将其写入USB闪存驱动器或DVD光盘。2.创建一个虚拟机,选择Linux操作系统类型为“其他”,然后选择“自定义”选项。3.在“自定义”选项中...
- 最精简的win10系统(最精简win10是哪个版本)
-
好因为win10精简系统相比原版系统,减少了很多无用的软件和功能,使系统更加流畅稳定,启动速度更快,同时占用的磁盘空间也更小,使得电脑更加高效。另外,使用者可以根据自己的需要灵活安装所需软件,提高工作...
- windows32位是什么意思(win7 32位是什么意思)
-
区别:1、表示32bit:X8664bit:X642、处理数据的能力32位计算机的CPU一次最多能处理32位数据,例如它的EAX寄存器就是32位的,32位计算机通常也可以处理16位和8位数据。64...
-
- 电脑突然不动了没反应(电脑突然就动不了了)
-
以excel为例,解决办法如下:1.发现拖动图表了,但是有一部分页面没有发生变化,按理说应该消失的,这个和大家遇到的整个页面不动是一样的原因。2.根本原因都是窗口被冻结导致的,所以在遇到这类问题就可以直接把窗口解冻就OK了。先找到“视图”这...
-
2025-12-14 04:03 off999
欢迎 你 发表评论:
- 一周热门
-
-
抖音上好看的小姐姐,Python给你都下载了
-
全网最简单易懂!495页Python漫画教程,高清PDF版免费下载
-
Python 3.14 的 UUIDv6/v7/v8 上新,别再用 uuid4 () 啦!
-
飞牛NAS部署TVGate Docker项目,实现内网一键转发、代理、jx
-
python入门到脱坑 输入与输出—str()函数
-
宝塔面板如何添加免费waf防火墙?(宝塔面板开启https)
-
Python三目运算基础与进阶_python三目运算符判断三个变量
-
(新版)Python 分布式爬虫与 JS 逆向进阶实战吾爱分享
-
失业程序员复习python笔记——条件与循环
-
使用 python-fire 快速构建 CLI_如何搭建python项目架构
-
- 最近发表
- 标签列表
-
- 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)
