Python 检查元组中是否存在项目
检查元组中是否存在项目
要确定元组中是否存在指定项目,请使用 in
关键字
示例
检查元组中是否存在 "apple"
thistuple = ("apple", "banana", "cherry")
if "apple" in thistuple
print("Yes, 'apple' is in the fruits tuple")
自己试试 »
要确定元组中是否存在指定项目,请使用 in
关键字
检查元组中是否存在 "apple"
thistuple = ("apple", "banana", "cherry")
if "apple" in thistuple
print("Yes, 'apple' is in the fruits tuple")
自己试试 »
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]
If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]