代码之家  ›  专栏  ›  技术社区  ›  Limina102

Python中是否有`(void)foo`的等价物[[副本]

  •  1
  • Limina102  · 技术社区  · 5 年前

    (void)foo 用于说明变量 foo

    static int callback(const char *path, void *buf, fuse_fill_dir_t filler,
                        off_t offset, struct fuse_file_info *fi)
    {
        (void) offset;
        (void) fi;
    ...
    

    如何在Python中正确地实现这一点?比如,当按行迭代一个表时,有一个不需要的列 func ,Python的叫嚣方式是什么 这里没有要求吗?代码如下:

    for no, msg, func in TABLE:
        print(f'[{no}] {msg}')
    
    1 回复  |  直到 5 年前
        1
  •  2
  •   Yusuf    5 年前

    我相信您正在寻找下划线,它几乎符合您所想的目的。

    在下面的示例中, _

    for _ in range(10):
         print("Hello world")
    

    You can take a look at this question for more details