畅享聊:python切片及数据类型转换
off999 2024-09-13 13:36 82 浏览 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
审核|闫庆红
相关推荐
- 惠普电脑bios设置u盘启动(惠普 bios u盘启动)
-
惠普电脑bios设置u盘启动:1、插上制作好的u启动启动盘的u盘并启动电脑,在进入开机画面的时候按“f2”进入bios界面;2、进入bios界面之后切换到“boot”,准备设置u盘启动;3、这里在键盘...
- win7优化开机启动项(windows10启动项优化)
-
开机出现错误0xc0000017无法开机错误的解决办法。1、就是system文件丢失了。2、如果想来恢复正常,需要有U盘或者光盘的pe系统,在pe下修复。3、本身C:\Windows\System32...
- 默认浏览器怎么改(软件默认浏览器怎么改)
-
在浏览器中设置默认浏览器的方法略有不同,以下是在常见的几个浏览器中设置默认浏览器的方法:1.在Windows10中设置Edge浏览器为默认浏览器: a.打开...
- 显卡驱动程序是什么
-
NVIDIA驱动是一种软件,用于管理安装在计算机上的NVIDIA图形处理器,以确保它们正常运行。NVIDIA是一家知名的GPU(图形处理器)制造商,提供各种高性能显卡和集成GPU,这些设备需要相应的驱...
-
- 扣扣空间电脑版登录入口(qq空间电脑版官网网站登录)
-
可以通过以下链接登陆进入QQ空间:https://qzone.qq.com/QQ空间(Qzone)是腾讯公司于2005年开发出来的一个具有个性空间,具有博客(blog)的功能,自问世以来受到众多人的喜爱。在QQ空间上可以书写日志、写说说...
-
2025-12-27 22:03 off999
- 怎么还原(怎么还原手机出厂设置)
-
1、首先,在Excel工作表中依次点击左上角的文件图标——Excel选项。2、然后,在弹出来的Excel选项的小窗口中点击左侧的保存菜单栏目。3、接着,在保存菜单栏目的右侧可以看到自动恢复文件的位置,...
- 怎么用360升级系统版本(怎么用360更新系统)
-
360可以下载补丁更新漏洞,对系统进行升级(在360修复漏洞里面点立即修复就行了)升级电脑系统大多数情况下是指低版本的系统升级到高版本的系统,比如说从windows2000升到xp,从vista升级到...
- 360助手电脑版客户端(360软件助手电脑)
-
还是非常好的,都是能够让他可以直接拦截病毒,同时能够让他清理内存,而且能够让这个有非常好的手机应用软件权限优化作用。360手机助手是360推出的手机助手,拥有海量软件和游戏轻松下载,炫彩主题壁纸随心点...
- 手机360助手官网下载(手机360助手最新版下载)
-
1、在电脑上安装360安全卫士打开它里边里的360手机助手2、手机设置系统设置——应用程序——未知来源打钩——开发USB调试打钩允许模拟位置打钩3、连接电脑、手机,并打开手机助手4、手机助...
- window10安装密钥(win10安装密钥命令)
-
以专业版为例,win10密钥是由25个字符组成的代码,用于激活windows,根据用户获取windows10副本的方式,需要由25个字符组成的产品密钥或数字许可证才能激活它。数字许可证是windows...
- 电脑windows7无法连接到网络
-
解决方法:1、在使用电脑的时候,出现了网络连接不可用的问题,可能造成的原因主要有网络连接被禁用,DNS和IP地址获取不对,网卡驱动损坏,网线没有插好。2、鼠标右键网络连接图标进去,点击更改适配器设置。...
- 路由器静态ip填什么(路由器的静态ip)
-
手机登入路由器web界面,输入用户名和密码,第一次弹出设置向导,选择静态ip上网方式,填写可以上网的ip地址,如ip192.168.1.188子网掩码255.255.255.0网关192.168....
欢迎 你 发表评论:
- 一周热门
-
-
抖音上好看的小姐姐,Python给你都下载了
-
全网最简单易懂!495页Python漫画教程,高清PDF版免费下载
-
Python 3.14 的 UUIDv6/v7/v8 上新,别再用 uuid4 () 啦!
-
飞牛NAS部署TVGate Docker项目,实现内网一键转发、代理、jx
-
python入门到脱坑 输入与输出—str()函数
-
宝塔面板如何添加免费waf防火墙?(宝塔面板开启https)
-
Python三目运算基础与进阶_python三目运算符判断三个变量
-
(新版)Python 分布式爬虫与 JS 逆向进阶实战吾爱分享
-
失业程序员复习python笔记——条件与循环
-
系统u盘安装(win11系统u盘安装)
-
- 最近发表
- 标签列表
-
- 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)
