当前位置:网站首页>14 - 容器-元组
14 - 容器-元组
2022-04-22 05:39:00 【ʕ·͡ˑ·ཻʔ**ʕ·͡ˑ·ཻʔ】
目录
一、元组
-
元组的 两种定义方式:
-
作用:主要用于传参和返回值。
-
注意:
二、元组的查询方法
-
作用:查出指定索引所对应的具体数据。
-
语法:元组[索引]
-
注意:使用不存在的索引,代码执行会报错。
-
作用:查出并返回 指定数据在元组中 第一次出现的位置。
-
语法:num = 元组.index(指定数据)。
-
作用:统计并返回 指定数据在元组中 出现的次数。
-
语法:num = 元组.count(指定数据)
三、元组支持切片
-
作用:使用切片操作,可以一次性获取元组中的多个数据。
-
语法:元组[start:end:step]
四、元素的特殊用法:交换两个变量的值【面试题】
-
1. 在Python中,定义包含多个元素的元组时,小括号可以省略。
-
2. 在Python中,可以使用,对应数据个数的变量,获取对应元组数据中的每一个元素。
版权声明
本文为[ʕ·͡ˑ·ཻʔ**ʕ·͡ˑ·ཻʔ]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_46071165/article/details/124302107
边栏推荐
- LeetCode 1770. 执行乘法运算的最大分数 -- 区间DP
- MySQL functions and exercises (II)
- Discounted split plane
- C語言--經典100題
- Data mining -- decision tree classification
- Simple DP questions - cow breeding and super stair climbing
- 蓝桥杯31天冲刺 Day5
- Torch recurrent neural network nn. RNN () and torch nn. RNNCell()
- uniapp:HBuilderX运行uniapp项目到夜神模拟器
- 数据挖掘——序列模式挖掘
猜你喜欢
随机推荐
棋盘覆盖问题(分治)
Program compilation (preprocessing operation) + link
vs 断点无法调试 The breakpoint will not currently be hit. No symbols have been loaded for this document.
Data mining -- sequential pattern mining
数据挖掘——聚类
C language -- classic 100 questions
layer关闭弹窗,刷新父页面
LeetCode 589. N 叉树的前序遍历
LeetCode 99. 恢复二叉搜索树 -- 中序遍历+排序
torch nn.Parameter可训练参数定义
整数拆分问题(动态规划+递归&记录数组)
蓝桥杯31天冲刺 Day14
数据挖掘——认识数据
torch 循环神经网络torch.nn.RNN()和 torch.nn.RNNCell()
Coordinate conversion using Gaode map API: WGS84 → gcj02
Force buckle 237 Delete specified node list
Optimization theory: transportation problem (I) finding the minimum freight [northwest corner method, minimum element method, Vogel method]
ip数据报中首部 总长度 片偏移的单位
LeetCode 467. Dynamic programming -- the only substring in the surrounding string
excel的相对引用和绝对引用








