2024-06-01 02:24:00 发布
网友
以下是我目前所拥有的,但不起作用:
if "Forwarder" not in shp_name or "T_" not in shp_name or "Grad" not in shp_name:
我也试过:
输入的样本将是“DS_Forwarder_1”或“DS_Harvester_1”。脚本直接前进到else,因为它无法在主字符串中标识上述任何子字符串。在
else
尝试使用内置的any。在
any
if any(s in shp_name for s in ("Forwarder", "T_", "Grad")): ...
如果shp_name中存在任何给定的字符串,则这将是真的。如果在其中一个字符串存在时想要False,可以使用if not any(...。在
shp_name
if not any(...
尝试使用内置的
any
。在如果
shp_name
中存在任何给定的字符串,则这将是真的。如果在其中一个字符串存在时想要False,可以使用if not any(...
。在相关问题 更多 >
编程相关推荐