python判断字符串在不在列表里
可以使用in关键字来判断一个字符串是否在列表中。示例如下:
string = "hello"
string_list = ["hello", "world", "python"]
if string in string_list:
print("字符串存在于列表中")
else:
print("字符串不存在于列表中")
输出结果为:"字符串存在于列表中"。
原文地址: https://www.cveoy.top/t/topic/iCWx 著作权归作者所有。请勿转载和采集!