python-any函数;判断数组内的元素是否存在于字符串内

代码:

city=['深圳','上海','北京','杭州']

address='我家住在大中国的杭州'

if any(element in address for element in city):

print("字符串“%s”包含city内的字符串"%address)

输出:

猜你喜欢

转载自blog.csdn.net/weixin_43934631/article/details/129183640
今日推荐