python怎么创建一个空元组
导读:python怎么创建一个空元组?在python中,我们也可以创建一个没有任何元素的元组 。 使用一对圆括号( 创建一个空元组 。Syntax:句法:tuple_name = ( Example 1:范例1:# Python empty tu...
python怎么创建一个空元组?
在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):
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
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: python怎么创建一个空元组
本文地址: https://pptw.com/jishu/59849.html
