📜  python 追加到元组列表 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:39.847000             🧑  作者: Mango

代码示例1
apple = ('fruit', 'apple')
banana = ('fruit', 'banana')
dog = ('animal', 'dog')
# Make a list with these tuples
some_list = [apple, banana, dog]
# Check if it's actually a tuple list
print(some_list)
# Make a tuple to add to list
new_thing = ('animal', 'cat')
# Append it to the list
some_list.append(new_thing)
# Print it out to see if it worked
print(some_list)