python 初始化 元组_在Python中重新初始化元组
生活随笔
收集整理的這篇文章主要介紹了
python 初始化 元组_在Python中重新初始化元组
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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.aspx
python 初始化 元組
總結
以上是生活随笔為你收集整理的python 初始化 元组_在Python中重新初始化元组的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 《蜀四贤咏》第十八句是什么
- 下一篇: 光纤宽带一年多少钱啊?