畅享聊:python切片及数据类型转换
off999 2024-09-13 13:36 60 浏览 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
审核|闫庆红
相关推荐
- 阿里云国际站ECS:阿里云ECS如何提高网站的访问速度?
-
TG:@yunlaoda360引言:速度即体验,速度即业务在当今数字化的世界中,网站的访问速度已成为决定用户体验、用户留存乃至业务转化率的关键因素。页面加载每延迟一秒,都可能导致用户流失和收入损失。对...
- 高流量大并发Linux TCP性能调优_linux 高并发网络编程
-
其实主要是手里面的跑openvpn服务器。因为并没有明文禁p2p(哎……想想那么多流量好像不跑点p2p也跑不完),所以造成有的时候如果有比较多人跑BT的话,会造成VPN速度急剧下降。本文所面对的情况为...
- 性能测试100集(12)性能指标资源使用率
-
在性能测试中,资源使用率是评估系统硬件效率的关键指标,主要包括以下四类:#性能测试##性能压测策略##软件测试#1.CPU使用率定义:CPU处理任务的时间占比,计算公式为1-空闲时间/总...
- Linux 服务器常见的性能调优_linux高性能服务端编程
-
一、Linux服务器性能调优第一步——先搞懂“看什么”很多人刚接触Linux性能调优时,总想着直接改配置,其实第一步该是“看清楚问题”。就像医生看病要先听诊,调优前得先知道服务器“哪里...
- Nginx性能优化实战:手把手教你提升10倍性能!
-
关注△mikechen△,十余年BAT架构经验倾囊相授!Nginx是大型架构而核心,下面我重点详解Nginx性能@mikechen文章来源:mikechen.cc1.worker_processe...
- 高并发场景下,Spring Cloud Gateway如何抗住百万QPS?
-
关注△mikechen△,十余年BAT架构经验倾囊相授!大家好,我是mikechen。高并发场景下网关作为流量的入口非常重要,下面我重点详解SpringCloudGateway如何抗住百万性能@m...
- Kubernetes 高并发处理实战(可落地案例 + 源码)
-
目标场景:对外提供HTTPAPI的微服务在短时间内收到大量请求(例如每秒数千至数万RPS),要求系统可弹性扩容、限流降级、缓存减压、稳定运行并能自动恢复。总体思路(多层防护):边缘层:云LB...
- 高并发场景下,Nginx如何扛住千万级请求?
-
Nginx是大型架构的必备中间件,下面我重点详解Nginx如何实现高并发@mikechen文章来源:mikechen.cc事件驱动模型Nginx采用事件驱动模型,这是Nginx高并发性能的基石。传统...
- Spring Boot+Vue全栈开发实战,中文版高清PDF资源
-
SpringBoot+Vue全栈开发实战,中文高清PDF资源,需要的可以私我:)SpringBoot致力于简化开发配置并为企业级开发提供一系列非业务性功能,而Vue则采用数据驱动视图的方式将程序...
- Docker-基础操作_docker基础实战教程二
-
一、镜像1、从仓库获取镜像搜索镜像:dockersearchimage_name搜索结果过滤:是否官方:dockersearch--filter="is-offical=true...
- 你有空吗?跟我一起搭个服务器好不好?
-
来人人都是产品经理【起点学院】,BAT实战派产品总监手把手系统带你学产品、学运营。昨天闲的没事的时候,随手翻了翻写过的文章,发现一个很严重的问题。就是大多数时间我都在滔滔不绝的讲理论,却很少有涉及动手...
- 部署你自己的 SaaS_saas如何部署
-
部署你自己的VPNOpenVPN——功能齐全的开源VPN解决方案。(DigitalOcean教程)dockovpn.io—无状态OpenVPNdockerized服务器,不需要持久存储。...
- Docker Compose_dockercompose安装
-
DockerCompose概述DockerCompose是一个用来定义和管理多容器应用的工具,通过一个docker-compose.yml文件,用YAML格式描述服务、网络、卷等内容,...
- 京东T7架构师推出的电子版SpringBoot,从构建小系统到架构大系统
-
前言:Java的各种开发框架发展了很多年,影响了一代又一代的程序员,现在无论是程序员,还是架构师,使用这些开发框架都面临着两方面的挑战。一方面是要快速开发出系统,这就要求使用的开发框架尽量简单,无论...
- Kubernetes (k8s) 入门学习指南_k8s kubeproxy
-
Kubernetes(k8s)入门学习指南一、什么是Kubernetes?为什么需要它?Kubernetes(k8s)是一个开源的容器编排系统,用于自动化部署、扩展和管理容器化应用程序。它...
欢迎 你 发表评论:
- 一周热门
-
-
抖音上好看的小姐姐,Python给你都下载了
-
全网最简单易懂!495页Python漫画教程,高清PDF版免费下载
-
Python 3.14 的 UUIDv6/v7/v8 上新,别再用 uuid4 () 啦!
-
python入门到脱坑 输入与输出—str()函数
-
宝塔面板如何添加免费waf防火墙?(宝塔面板开启https)
-
Python三目运算基础与进阶_python三目运算符判断三个变量
-
(新版)Python 分布式爬虫与 JS 逆向进阶实战吾爱分享
-
飞牛NAS部署TVGate Docker项目,实现内网一键转发、代理、jx
-
慕ke 前端工程师2024「完整」
-
失业程序员复习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)
