畅享聊:python切片及数据类型转换
off999 2024-09-13 13:36 98 浏览 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
审核|闫庆红
相关推荐
- 笔记本电脑怎么连接家里的无线网
-
第一步,首先找到你家的WIFI名称,找到WIFI名称以后直接输入你家的WIFI密码,第二步直接连接上你家的WIFI密码就可以连接到你家的网络上了,连接好了以后就可以正常使用你就的网络了,在网上看电影,...
- 苹果手机ios在哪里打开(苹果手机如何打开ios)
-
1、开启苹果手机,进入主界面,选择“设置”菜单。2、进入“设置”菜单后,选择我们的“苹果帐号”点击进入。3、进入我们的苹果帐号菜单后,将页面滑动到最底部,选择当期操作的手机。4、点击“当期操作的手机”...
- win10误删注册表如何恢复(win10误删注册表导致开始菜单打不开)
-
如果您的Windows10注册表遇到了问题,您可以尝试以下几种方法来恢复它:1.创建注册表备份:在恢复之前,最好先创建注册表的备份以防止意外情况。打开注册表编辑器,选择“文件”菜单,然后选择“导出...
- 怎样用u盘安装系统教程(用u盘怎么安装系统)
-
制作启动盘:将U盘格式化为FAT32,然后使用Rufus或其他工具将系统镜像文件写入U盘。启动电脑:将制作好的U盘插入电脑USB接口,并开机。在电脑启动时,按下启动菜单键(通常是...
- 找不到ie浏览器怎么办(ie浏览器电脑里找不到)
-
首先我们打开“开始”菜单,看看菜单左面里有没有ie浏览器,或者直接在“所有程序”的位置,搜索“internet”,看看能不能找到我们的ie浏览器。若是可以找到这个程序,直接使用鼠标的右键,在菜单中找到...
- 以太网未连接怎么解决(怎么把以太网改成wifi)
-
1.IP地址设置是否有效按setting,选择网络,设置IP地址和网关。测量仪器应与PC机处于同一个网段,跨网段搜索连接可能会失败,若PC机IP:192.168.4.XXX,测量仪器IP地址和网关也应...
- win7如何进入bios界面(Win7如何进入bios界面)
-
在Win7开机时进入BIOS设置是通过按下特定的按键来实现的。不同的计算机品牌和型号可能需要不同的按键组合来进入BIOS设置,请注意电脑启动时屏幕上的提示信息,通常会显示要使用哪个按键来进入BIOS。...
- 装机配置表(装机配置表格下载)
-
处理器+主板:I39100+技嘉B360M套装1179散热:九州风神玄冰40099显卡:核显内存:金士顿dr426668G279固态:三星250GB860EVO(SATA3.0)33...
- apple id怎么找回密码(Apple ID怎么找回密码没有苹果手机)
-
可以用ID找回密码。因为在注册Apple账号时必须要添加邮箱或手机号码,所以当忘记密码时,可以通过输入该账号的邮箱或手机号码来找回密码。具体步骤为:在登录页面点击“忘记密码”,选择“使用其他方式找回”...
- 电脑磁盘受损怎样修复(电脑磁盘损坏)
-
方法一:一般问题修复 1.硬盘坏常的现象是开机或运行时容易蓝屏,但还是能进系统。这个问题一般比较的容易修复,主要是系统分区出问题了。我们打开DOS命令提示符窗口,输入命令“chkdskc:/f...
- mac地址在哪里查(mac地址在哪里查找啊)
-
查看电脑MAC地址的五种方法如下:方法一:通过命令提示符查看点击“开始”菜单,在“搜索程序和文件”输入框中输入“cmd”,然后回车。回车后,弹出命令符窗口,输入“ipconfig/all”,然后回车。...
- win10u盘系统盘制作(win10u盘做系统详细步骤)
-
要用U盘制作一个Windows10系统盘,您可以按照以下步骤进行操作:1. 准备一个至少8GB容量的U盘,并确保其中没有重要数据,因为制作系统盘会将U盘格式化。2.&n...
- 电脑怎么更新win10(电脑怎么更新浏览器)
-
windows10升级版本方法如下一、首先,打开要更新的电脑,进入win10系统,在桌面左下角点击“开始”按钮。二、然后,在“开始”菜单中点击“设置”点击打开。三、然后,在电脑设置中选择“更新与安全”...
- 联想电脑恢复出厂设置系统(联想系统恢复出厂系统)
-
1.打开电脑,鼠标点击屏幕左下角的【开始】图标,再点击【设置】图标。 2.进入【Windows设置】界面后,点击【更新和安全】-【恢复】。 3.点击【重置此电脑】下的【开始】按钮,根据需要选择【保...
- 手机版爱思助手app下载苹果版
-
第一步:我们先在电脑上安装好爱思助手,并且把手机与电脑连接起来; 第二步:在电脑上打开爱思助手以后,点击顶部的“软件资源”栏目; 第三步:随后在软件资源列表中即可看到“爱思助手”应用,点击...
欢迎 你 发表评论:
- 一周热门
-
-
抖音上好看的小姐姐,Python给你都下载了
-
全网最简单易懂!495页Python漫画教程,高清PDF版免费下载
-
飞牛NAS部署TVGate Docker项目,实现内网一键转发、代理、jx
-
Python 3.14 的 UUIDv6/v7/v8 上新,别再用 uuid4 () 啦!
-
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)
