图片素材网站排行榜,泉州网站建设设计,多用户智能网站建设源码,安全舆情监测平台python 初始化 元组Python | 重新初始化元组 (Python | Reinitializing tuple) In this tutorial, we will learn how can we reinitialize a tuple with a new set of elements/objects? 在本教程中#xff0c;我们将学习如何使用一组新的元素/对象重新初始化元组#xff1…python 初始化 元组 Python | 重新初始化元组 (Python | Reinitializing tuple) In this tutorial, we will learn how can we reinitialize a tuple with a new set of elements/objects? 在本教程中我们将学习如何使用一组新的元素/对象重新初始化元组 To reinitialize a tuple, we can use tuple() or a pair of round brackets (), the steps are, 要重新初始化元组 我们可以使用tuple()或一对圆括号() 步骤是 Reinitialize the tuple using () or tuple() 使用()或tuple()重新初始化元组 Reassign the new set of objects/elements 重新分配新的对象/元素集 Consider the below program, 考虑下面的程序 # Reinitializing a tuple in Python
# tuple creation
x (Shivang, 21, Indore, 9999867123)
# printing original tuple
print(x: , x)
print(len(x): , len(x))
print(type(x): , type(x))
print()
# Reinitializing tuple using tuple()
x tuple()
# assigning new objects
x (10, 20, 30, 40, 50)
print(x: , x)
print(len(x): , len(x))
print(type(x): , type(x))
print()
# Reinitializing tuple using ()
x ()
# assigning new objects
x (Amit, 18, Jaipur, 98.24, 8888888888)
print(x: , x)
print(len(x): , len(x))
print(type(x): , type(x))
print()
Output 输出量 x: (Shivang, 21, Indore, 9999867123)
len(x): 4
type(x): class tuple
x: (10, 20, 30, 40, 50)
len(x): 5
type(x): class tuple
x: (Amit, 18, Jaipur, 98.24, 8888888888)
len(x): 5
type(x): class tuple
翻译自: https://www.includehelp.com/python/reinitializing-a-tuple.aspxpython 初始化 元组