元组的关键字是什么?

-4 python tuples

我正在尝试查找tuple关键字“列表”之类的关键字

这是我的例子:

输入:

list1 = [1, 2, 3]
if type(list1) == list:
    print("this is a list")
Run Code Online (Sandbox Code Playgroud)

输出:

this is a list
Run Code Online (Sandbox Code Playgroud)

我想知道元组而不是列表的关键字是什么。

qua*_*ana 5

你可以只使用tuple. 您可能还想使用isinstance

tuple1 = (1, 2, 3)
if isinstance(tuple1, tuple):
    print("this is a tuple")
Run Code Online (Sandbox Code Playgroud)