Modify python string with contain method
This question already has an answer here:
您可以简单地使用in
关键字,如下所示:
if 'Word' in myfile:
print myfile
你可以用find来替换contains,只需检查一个非-1的返回码。
for myfile in filelist:
if myfile.find("Word")!=-1:
print myfile
链接地址: http://www.djcxy.com/p/9388.html
下一篇: 用包含方法修改python字符串