小编rea*_*aco的帖子

列表解析中的Python any()函数

我是Python的新手(2周!)并且正在努力解决以下问题:

我有一个URL列表,我想迭代并找到某些URL.为此,我想测试URL中存在元组的任何成员.

我已经发现我需要一个any()语句,但无法正确获取语法:

allurls = [<big list of URLs>]

words = ('bob', 'fred', 'tom')

urlsIwant = [x for x in allurls if any(w for w in words) in x]
Run Code Online (Sandbox Code Playgroud)

抓住我

TypeError: 'in <string>' requires string as left operand, not bool
Run Code Online (Sandbox Code Playgroud)

我不认为它是相关的,但我的实际代码是

urlsIwant = sorted(set([x for x in allurls if dict['value'] in x and any(w for w in words) in x]))
Run Code Online (Sandbox Code Playgroud)

python list-comprehension

10
推荐指数
1
解决办法
5137
查看次数

关闭vimrc中的gitgutter

我已经安装了gitgutter, 并希望默认关闭它.文档说使用

:GitGutterDisable

去做这个.如果我在vim会话中这是有效的.但是我想将它添加到我的vimrc中以使其永久化.

我已经尝试在vimrc中调整其他插件命令,例如

let g:GitGutterDisable
Run Code Online (Sandbox Code Playgroud)

和其他各种组合,但不能让该死的东西关闭.我还查看了〜/ .vim/bundle/vim-gitgutter/plugin/gitgutter.vim并在那里摆弄了一些设置.

我接近将下面设置为零

call s:set('g:gitgutter_enabled',                     1)
Run Code Online (Sandbox Code Playgroud)

但这只是永久关闭它,即:vim命令行上的GitGutterSignsToggle不再有效

vim vim-plugin

2
推荐指数
1
解决办法
731
查看次数

标签 统计

list-comprehension ×1

python ×1

vim ×1

vim-plugin ×1