如何在if语句中扫描列表
-
20-12-2019 - |
题
我有一个python 3.3程序,我想有一个如下工作。我怎样才能查看该列表?它只是给了我一个错误!
app_list = ["Item1", "Item2", Item3"]
elif menu == "open " + in app_list:
do_stuff()
. 解决方案
听起来你想要的东西:
app_list = ["Item1", "Item2", "Item3"]
elif menu.startswith("open ") and menu[5:] in app_list:
do_stuff()
. 不隶属于 StackOverflow