畅享聊:python切片及数据类型转换
off999 2024-09-13 13:36 83 浏览 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
审核|闫庆红
相关推荐
- win98安装教程(win98iso怎么安装)
-
如何安装windows98 一、具体安装步骤 备份好重要文件之后,就可以安装windows98了。 第一步:启动安装程序。 用户如果原来已安装了windows95/97/98,现在拟对其进行升...
- 雨林木风win7安装(雨林木风win732位安装教程)
-
安装步骤如下: 1、光盘放入光驱,复制光盘上的win7.gho和安装系统.exe到硬盘非C盘的文件夹;(gho文件名可以是其他名字,后缀为gho,体积最大的就是。) 2、双击安装系统.exe;...
- win10解绑管理员账户(win10管理员账户怎么取消开机密码)
-
要解除Windows10电脑上的管理员权限,您需要进行以下操作:1.打开“控制面板”:右键单击“开始”按钮,然后选择“控制面板”。2.进入“用户账户”:在控制面板中,选择“用户账户”。3.点击...
- win10家庭版没有组策略编辑器
-
Win10组策略编辑器找不到怎么办 解决方法 一、win10系统版本本身不提供组策略的功能。 1、运行gpedit.msc直接提示找到gpedit.msc(组策略)。 2、运行MMC,在“添加...
- tplogin管理员登录入口(tplogin重新设置密码)
-
tplogin.cn是新版tplink路由器的登录地址(管理页面地址),在浏览器中输入tplogin.cn,就可以打开tplink路由器的管理页面(登录页面)。具体的登录方法如下:1、打开电脑上的浏...
- psp模拟器怎么导入游戏(psp模拟器怎么导入游戏 Vivo手机)
-
方法如下:1、打开能操作文件的助手软件,用pp链接后点击左下文件,然后点常用目录下的程序用户,会出现ppsspp的文件夹。2、打开ppsspp文件夹,会出来四个选项文件夹,第一个进去后是psp文件夹,...
- 电脑系统怎样升级(电脑系统怎么升级)
-
电脑系统升级方法步骤,1、打开电脑,点击电脑左下角的开始菜单,在弹出的菜单选项中选择“控制面板”。2、点击“开始”,点击“控制面板”3、在控制面板中,点击“系统和安全”。4、点击启用或禁用自动更新。5...
- windows无法激活(windows无法激活有什么影响)
-
1.如果修复或重新组装了电脑,则可能是安装了不同版本的Windows。或者,如果在修复过程中为电脑使用了其他产品密钥,当使用该密钥的电脑数大于Microsoft软件许可条款允许的电脑数时,该密钥...
-
- u盘文件恢复软件免费(恢复u盘数据免费的软件)
-
u盘损坏文件恢复方法:1、打开电脑桌面的“计算机”或“我的电脑”。2、然后再找到需要修复的u盘。3、打开“运行”窗口(可以直接按“Windows+R”快捷打开),输入“CMD”并点击“确定”按钮以进入命令提符界面。4、从打开的“命令提示符”...
-
2025-12-28 22:03 off999
- 电脑uac是什么意思
-
UAC就是用户帐户控制,在对计算机进行更改之前,用户帐户控制(UAC)会通知您。比如安装软件驱动什么的,默认UAC设置会在程序尝试对计算机进行更改时通知您,但您可以通过调整设置来控制UAC...
- 笔记本找不到自己家的wifi怎么办
-
1.笔记本电脑缺少无线网卡驱动,需要下载驱动如果笔记本电脑开机之后,无法显示WiFi网络的图标,这个时候多半是因为电脑缺少无线网卡驱动造成的,有时候自己在清理电脑的时候,不小心清理了驱动程序,便会...
- 电信宽带办理电话是多少(电信宽带办理联系电话)
-
电信宽带不一定需要电信手机号码,可以根据自身需要选择,有单独的宽带业务,一般要求预存一定时间的使用费。不过一般包含了宽带、手机号码的融合套餐总体上更优惠,对客户来说更划算。如果有相应需求的话,建议同时...
欢迎 你 发表评论:
- 一周热门
-
-
抖音上好看的小姐姐,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)
