我有一个字符串,如search = 'hello'
,需要检查整个数组,看是否包含hello
。
例如:
"hello" == "123hello123" | true
"hello" == "aasdasdasd123hello123" | true
"hello" == "123123hello" | true
我需要类似于代码搜索的东西
list_all_files_in_google_drive
- 这是我的所有文件名数组
filename
- 文件名,需要检查它是否存在于谷歌云端硬盘中
if not any(file['title'] == filename for file in list_all_files_in_google_drive):
print('file not exist')
我的代码不能正常工作是因为它的工作方式如下:
"hello" == "123hello123" | false
"hello" == "aasdasdasd123hello123" | false
"hello" == "123123hello" | false
"hello" == "hello" | true
我需要它像这样工作:
我需要按照以下方式运行:
"hello" == "123hello123" | true
"hello" == "aasdasdasd123hello123" | true
"hello" == "123123hello" | true
"hello" == "hello" | true
更新:
我检查了运算符 in
,它没有输出true
。
filename = 'hello'
list = ['123hello123', 'aasdasdasd123hello123', '123123hello']
if filename in list:
print('true')