查找字符串列表中至少有一个字符串是否没有字符(python)

时间:2018-02-17 22:14:23

标签: python any

我想检查一下字符串列表中的元素中是否至少有一个元素没有" - "在里面。我试过了:

my_list = ['gta', '---', '---', 'gta']

使用:

True

它应该返回my_list = ['gt-', 'ac-', 'ca-', 'gt-'] 并使用:

False

它应该返回False。它现在总是function getSection(arr, x, y) { var section = []; z = (y===0?0:y+y+2); arr = arr.slice(z, z+3); arr.forEach(function (element) { section.push(element.slice(z, z+3)); }) var subgrid = section.reduce(function (a, b) { return a.concat(b); }, [] ); return subgrid; } ,是否有单行命令来做到这一点?我可以选择简单的方法并将我的代码放在几行上,但我想练习这些命令:)。

2 个答案:

答案 0 :(得分:0)

正如评论中所述,由于not any变为all not,您需要使用not all

答案 1 :(得分:0)

您可以使用button=Button(x,y,width,height,text_color,background_color,text) while not done: for event in pygame.event.get(): if event.type==QUIT: terminate() elif event.type==pygame.MOUSEBUTTONDOWN: if dodger_button.check(): #what to do when button is pressed #fill screen with background screen.fill(background) button.draw() pygame.display.flip() clock.tick(fps) 检查列表中的整个字符串是否由re.findall组成:

"-"
相关问题