newechoes/src/content/理解计算机/python/元组.md

29 lines
544 B
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 元组
date: 2024-06-06T23:51:39Z
tags: []
---
## 概念
是 python 中内置的不可变数列
在 python 中使用()定义援助,元素与元素之间使用英文的逗号分隔
元组中只有一个元素的时候,逗号也不能省略
## 元组的创建方法
### 第一种直接创建
使用()直接创建元组
语法结构如下:
`元组名=(element1,element3,......,elementN)`
## 第二种使用内置函数 tuple
语法结构如下:
`元组名=tuple(序列)`
## 删除元组
`del 元组名`