用contain方法修改python字符串

use*_*059 7 python-2.7

我希望它在我的列表中找到以下文件:“ Microsoft Word 105Prt”(此文件名可能有所不同,但始终带有“ Word”。

for myfile in filelist:
    if myfile.contains("Word"): 
        print myfile
Run Code Online (Sandbox Code Playgroud)

我如何修改它以在python 2.7.5中工作,因为contains不起作用。

aru*_*nte 1

您可以简单地使用in关键字,如下所示:

if 'Word' in myfile:
    print myfile
Run Code Online (Sandbox Code Playgroud)