代码:
![](https://img-blog.csdnimg.cn/img_convert/a9a02a2889d50c134716328b9dafeca5.png)
city=['深圳','上海','北京','杭州']
address='我家住在大中国的杭州'
if any(element in address for element in city):
print("字符串“%s”包含city内的字符串"%address)
输出:
![](https://img-blog.csdnimg.cn/img_convert/24415bc4330d496f9756bd5d53e93293.png)
代码:
city=['深圳','上海','北京','杭州']
address='我家住在大中国的杭州'
if any(element in address for element in city):
print("字符串“%s”包含city内的字符串"%address)
输出: