python创建空元组_用Python创建空元组

python创建空元组

Python | 空元组 (Python | empty tuple)

In python, we can also create a tuple without having any element. An empty tuple is created using a pair of round brackets, ().

在python中,我们也可以创建一个没有任何元素的元组 。 使用一对圆括号()创建一个空元组

Syntax:

句法:

    tuple_name = ()

Example 1:

范例1:

# Python empty tuple creation`
tuple1 = () 
# printing tuple 
print("tuple1: ", tuple1)
# printing length
print("len(tuple1): ", len(tuple1))
# printing type
print("type(tuple1): ", type(tuple1))

Output

输出量

tuple1:  ()
len(tuple1):  0
type(tuple1):  <class 'tuple'>

Example 2:

范例2:

We can also create an empty tuple by initializing the tuple with tuple() – generally this method is used to clear/reinitialize the tuple.

我们也可以通过使用tuple()初始化元创建一个空元 组 -通常,此方法用于清除/重新初始化元组。

# Python empty tuple creation`
tuple1 = tuple() 
# printing tuple 
print("tuple1: ", tuple1)
# printing length
print("len(tuple1): ", len(tuple1))
# printing type
print("type(tuple1): ", type(tuple1))
print()
# non-empty tuple
tuple2 = (10, 20, 30, 40, 50)
# printing original tuple
print("tuple2: ", tuple2)
print()
# reinitialize
tuple2 = tuple()
print("After reinitialize...")
# printing tuple 
print("tuple2: ", tuple2)
# printing length
print("len(tuple2): ", len(tuple2))
# printing type
print("type(tuple2): ", type(tuple2))

Output

输出量

tuple1:  ()
len(tuple1):  0
type(tuple1):  <class 'tuple'>
tuple2:  (10, 20, 30, 40, 50)
After reinitialize...
tuple2:  ()
len(tuple2):  0
type(tuple2):  <class 'tuple'>

翻译自: https://www.includehelp.com/python/empty-tuple-creation.aspx

python创建空元组

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/540744.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

共享马扎的火爆,原来是一场营销!

如今&#xff0c;人们的生活仿佛已经被“共享化”&#xff1a;上班有共享单车、睡觉有共享床铺、商场有共享充电宝、去机场有共享巴士……好像除了男女朋友是自己的&#xff0c;其他都要共享了&#xff01;哎&#xff0c;不对&#xff01;前些日子&#xff0c;竟然还真有了共享…

什么是CDP(连续数据保护)?

CDP&#xff1a;连续数据保护 (CDP: Continuous Data Protection) CDP is an abbreviation of "Continuous Data Protection". It is also called as a real-time backup, is a system of data storage that backs up data in an organization or enterprise on a sy…

Git实战(二)原理

上次的博文Git实战&#xff08;一&#xff09;版本号控制概述中我们简介了一下版本号控制系统的概念&#xff0c;重点对版本号控制的三种类型进行了分析和对照&#xff0c;从本篇博文開始我们进入Git的世界&#xff0c;首先介绍一下Git实现版本号控制的原理。 Git与SVN等其它版…

什么是html的混杂模式_HTML的完整形式是什么?

什么是html的混杂模式HTML&#xff1a;超文本标记语言 (HTML: Hyper Text Markup Language) HTML is an abbreviation of Hypertext markup language. Hypertext markup language is a text based standard markup language used to create web pages and design documents whi…

PHP-Manual的学习----【语言参考】----【类型】-----【对象】

Object 对象1.对象初始化要创建一个新的对象 object &#xff0c;使用 new 语句实例化一个类&#xff1a; class foo{ function do_foo(){ echo "1111"; }}$bar new foo;echo $bar->do_foo();输出&#xff1a;1111注解&#xff1a;一个类可以初始化…

kotlin 两个数字相加_Kotlin程序交换两个数字

kotlin 两个数字相加Given two numbers, we have to swap them. 给定两个数字&#xff0c;我们必须交换它们。 Example: 例&#xff1a; Input:First number: 10Second number: 20Output:First number: 20Second number: 10To swap two numbers – here we are using third v…

Kotlin入门(14)继承的那些事儿

上一篇文章介绍了类对成员的声明方式与使用过程&#xff0c;从而初步了解了类的成员及其运用。不过早在《Kotlin入门(12)类的概貌与构造》中&#xff0c;提到MainActivity继承自AppCompatActivity&#xff0c;而Kotlin对于类继承的写法是“class MainActivity : AppCompatActiv…

在Scala中列出| 关于Scala列表的完整教程

Scala | 清单 (Scala | List) List in Scala is a collection that stores data in the form of a liked-list. The list is an immutable collection which means the elements of a list cannot be altered after the list is created. Lists are flexible with data types, …

MySQL单机多实例部署详解之------多实例分别定义不同的配置文件

mysql多实例安装---分别定义不同的配置文件1.安装MySQL需要的依赖包[rootMySQL ~]# yum install ncurses-devel libaio-devel cmake -y[rootMySQL ~]# rpm -qa ncurses-devel libaio-develncurses-devel-5.7-4.20090207.el6.x86_64libaio-devel-0.3.107-10.el6.x86_642.安装编译…

javascript模块_JavaScript中的模块

javascript模块JavaScript模块 (JavaScript Modules) One of the key features of programming fundamentals is breaking down your code into fragments. These fragments depending on its functionality have been coined various terms like functions, components, modul…

在mac上安装Docker

1.进入一下地址进行下载docker https://download.docker.com/mac/stable/Docker.dmg 进入后进行下载后进行安装 2.将其拖动到Appliaction中即可 3.第一打开会有一个这样的欢迎页面 3.检查是否安装完成 出现上图所示标示安装完成了

composer 检查镜像_检查N元树中的镜像

composer 检查镜像Problem statement: 问题陈述&#xff1a; Given two n-ary trees, the task is to check if they are mirrors of each other or not. 给定两个n元树&#xff0c;任务是检查它们是否互为镜像。 Note: you may assume that root of both the given tree as …

浪潮各机型前面板指示灯含义

NF560D2 NF3020M2 NF5020M3 NF5140M3 NF5212H2 NF5220 NF5224L2 NF5240M3 NF5270M3 NF5280M2 NF5280M3 NF5540M3 NF5580M3 NF8420M3 NF8520 NF8560M2 说明&#xff1a;转浪潮官网。

python dll 混合_Python | 条线混合图

python dll 混合In some of the cases, we need to plot a bar-line hybrid plot. This plot helps in a better understanding of dynamics as well as the relative magnitude of each point in the plot. Bar-Line Hybrid Plots are mostly used for the representation of …

测试八 赛后感受

测试八 当我打开T1的时候&#xff0c;就没有往下看题目了&#xff0c;主要是发现T1就是之前做过&#xff0c;而且我也看过题解的题目&#xff0c;接着就开始钻研&#xff0c;当然&#xff0c;也没什么好钻研的&#xff0c;大概思路还是知道的&#xff0c;再写写数据就已经很清晰…

推荐五个免费的网络安全工具

导读&#xff1a; 在一个完美的世界里&#xff0c;信息安全从业人员有无限的安全预算去做排除故障和修复安全漏洞的工作。但是&#xff0c;正如你将要学到的那样&#xff0c;你不需要无限的预算取得到高质量的产品。这里有SearchSecurity.com网站专家Michael Cobb推荐的五个免费…

bios部署模式审核模式_BIOS的完整形式是什么?

bios部署模式审核模式BIOS&#xff1a;基本输入输出系统 (BIOS: Basic Input Output System) BIOS is an abbreviation of the Basic Input Output System. In the beginning, when you first set on your computer, the first software which starts run by the computer is &…

day04-装饰器

一、装饰器定义 1&#xff09;装饰器&#xff1a;本质是函数。 2&#xff09;功能&#xff1a;用来装饰其他函数&#xff0c;顾名思义就是&#xff0c;为其他的函数添加附件功能的。 二、原则 1&#xff09;不能修改被装饰函数的源代码 2&#xff09;不能修改被装饰函数的调用方…

c 语言bool 类型数据_C ++中的bool数据类型

c 语言bool 类型数据In C programming language, to deal with the Boolean values – C added the feature of the bool data type. A bool variable stores either true (1) or false (0) values. 在C 编程语言中&#xff0c;为了处理布尔值– C 添加了bool数据类型的功能 。…

C ++中的std :: binary_search()

binary_search()作为STL函数 (binary_search() as a STL function) Syntax: 句法&#xff1a; bool binary_search (ForwardIterator first, ForwardIterator last, const T& value);Where, 哪里&#xff0c; ForwardIterator first iterator to start of the range For…