【问题标题】:redis-cli: How to change the output delimiter to the NUL character?redis-cli:如何将输出分隔符更改为 NUL 字符?
【发布时间】:2021-08-20 13:54:54
【问题描述】:

我喜欢获取集合的成员,NUL-separated。我该怎么办?

redis-cli SMEMBERS theset

使用换行符。

【问题讨论】:

    标签: database redis redis-cli


    【解决方案1】:

    我使用python 作为解决方法:

    #!/usr/bin/env python3
    
    import sys
    import redis
    r = redis.StrictRedis(host='localhost', port=6379, db=0)
    
    first = True
    for mem in r.smembers(sys.argv[1]):
        if not first:
            sys.stdout.buffer.write(b"\0")
    
        sys.stdout.buffer.write(mem)
        first = False
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-14
      • 1970-01-01
      • 2017-11-14
      相关资源
      最近更新 更多