使用单引号(')作为变量值

2024-05-16 18:39:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我最近安装了用python编写和配置的qtile,我习惯于使用包含单引号的keybinding '。此命令正在工作:

    Keys = [
        Key(
            ["mod4"], "m",
            lazy.screen.next_group()
        ),
    ]

我想要像这样的东西:

    Keys = [
        Key(
            ["mod4"], "'",               # <<- "m" got replaced by single quote
            lazy.screen.next_group()
        ),
    ]

它确实可以与m完美地配合使用,但如果我将其更改为',则不会。我能修好它吗?还是必须更改绑定


Tags: key命令bygroupkeysscreenlazynext
1条回答
网友
1楼 · 发布于 2024-05-16 18:39:51

个人不熟悉qtile,但来自the docs:

Special keys

These are most commonly used special keys. For complete list please see the code. You can create bindings on them just like for the regular keys. For example Key(["mod1"], "F4", lazy.window.kill()).

这里还有一个链接:https://github.com/qtile/qtile/blob/master/libqtile/xkeysyms.py,它在特殊键列表中声明'apostrophe': 0x0027,

这一切都向我表明,要绑定单引号,必须使用以下内容:

 Keys = [
    Key(
        ["mod4"], "apostrophe",
        lazy.screen.next_group()
    ),
]

相关问题 更多 >