s= '''<a href="https://ertfwetwer" target="_blank">[Nerve Center]</a>'''
my_list=['href','a']
def checker(mylist, my_string)
new = list()
for i in mylist:
if i in my_string: # if elements is in string (you can check only special elements )
print i ,'is in string'
new.append(i) #storing result to new list
checker (my_list, s)
检查字符串中列表元素的主要方法是:
输出:
但是因为你说我有一个来自页面源代码的长字符串,我想看看是.jpg还是.png或者.swf或者.wbm或者。。。。。。如果在里面,我想把它作为str
所以你想在你的代码中使用regex来查找所有的.jpg或者更多的字符串!假设你有
所以要检查
.jpg
和另一个格式化的您还可以找到他们的名字:
输出:
甚至
相关问题 更多 >
编程相关推荐