当前位置: 首页>>代码示例>>Python>>正文


Python time.seconds方法代码示例

本文整理汇总了Python中time.seconds方法的典型用法代码示例。如果您正苦于以下问题:Python time.seconds方法的具体用法?Python time.seconds怎么用?Python time.seconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在time的用法示例。


在下文中一共展示了time.seconds方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: blpop

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def blpop(self, keys, timeout=0):
        """
        LPOP a value off of the first non-empty list
        named in the ``keys`` list.

        If none of the lists in ``keys`` has a value to LPOP, then block
        for ``timeout`` seconds, or until a value gets pushed on to one
        of the lists.

        If timeout is 0, then block indefinitely.
        """
        if timeout is None:
            timeout = 0
        if isinstance(keys, basestring):
            keys = [keys]
        else:
            keys = list(keys)
        keys.append(timeout)
        return self.execute_command('BLPOP', *keys) 
开发者ID:leancloud,项目名称:satori,代码行数:21,代码来源:client.py

示例2: brpop

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def brpop(self, keys, timeout=0):
        """
        RPOP a value off of the first non-empty list
        named in the ``keys`` list.

        If none of the lists in ``keys`` has a value to LPOP, then block
        for ``timeout`` seconds, or until a value gets pushed on to one
        of the lists.

        If timeout is 0, then block indefinitely.
        """
        if timeout is None:
            timeout = 0
        if isinstance(keys, basestring):
            keys = [keys]
        else:
            keys = list(keys)
        keys.append(timeout)
        return self.execute_command('BRPOP', *keys) 
开发者ID:leancloud,项目名称:satori,代码行数:21,代码来源:client.py

示例3: strfage

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def strfage(time, fmt=None):
    """ Format time/age
    """
    if not hasattr(time, "days"):  # dirty hack
        now = datetime.utcnow()
        if isinstance(time, str):
            time = datetime.strptime(time, '%Y-%m-%dT%H:%M:%S')
        time = (now - time)

    d = {"days": time.days}
    d["hours"], rem = divmod(time.seconds, 3600)
    d["minutes"], d["seconds"] = divmod(rem, 60)

    s = "{seconds} seconds"
    if d["minutes"]:
        s = "{minutes} minutes " + s
    if d["hours"]:
        s = "{hours} hours " + s
    if d["days"]:
        s = "{days} days " + s
    return s.format(**d) 
开发者ID:xeroc,项目名称:piston-lib,代码行数:23,代码来源:utils.py

示例4: human_timedelta

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def human_timedelta(dt):
        now = datetime.utcnow()
        delta = now - dt
        hours, remainder = divmod(int(delta.total_seconds()), 3600)
        minutes, seconds = divmod(remainder, 60)
        days, hours = divmod(hours, 24)
        years, days = divmod(days, 365)

        if days:
            if hours:
                return '%s und %s' % (Plural(Tag=days), Plural(Stunde=hours))
            return Plural(day=days)

        if hours:
            if minutes:
                return '%s und %s' % (Plural(Stunde=hours), Plural(Minute=minutes))
            return Plural(hour=hours)

        if minutes:
            if seconds:
                return '%s und %s' % (Plural(Minute=minutes), Plural(Sekunde=seconds))
            return Plural(Minute=minutes)
        return Plural(Sekunde=seconds) 
开发者ID:Der-Eddy,项目名称:discord_bot,代码行数:25,代码来源:utility.py

示例5: time

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def time(self):
        """
        Returns the server time as a 2-item tuple of ints:
        (seconds since epoch, microseconds into this second).
        """
        return self.execute_command('TIME') 
开发者ID:leancloud,项目名称:satori,代码行数:8,代码来源:client.py

示例6: expire

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def expire(self, name, time):
        """
        Set an expire flag on key ``name`` for ``time`` seconds. ``time``
        can be represented by an integer or a Python timedelta object.
        """
        if isinstance(time, datetime.timedelta):
            time = time.seconds + time.days * 24 * 3600
        return self.execute_command('EXPIRE', name, time) 
开发者ID:leancloud,项目名称:satori,代码行数:10,代码来源:client.py

示例7: pexpire

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def pexpire(self, name, time):
        """
        Set an expire flag on key ``name`` for ``time`` milliseconds.
        ``time`` can be represented by an integer or a Python timedelta
        object.
        """
        if isinstance(time, datetime.timedelta):
            ms = int(time.microseconds / 1000)
            time = (time.seconds + time.days * 24 * 3600) * 1000 + ms
        return self.execute_command('PEXPIRE', name, time) 
开发者ID:leancloud,项目名称:satori,代码行数:12,代码来源:client.py

示例8: psetex

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def psetex(self, name, time_ms, value):
        """
        Set the value of key ``name`` to ``value`` that expires in ``time_ms``
        milliseconds. ``time_ms`` can be represented by an integer or a Python
        timedelta object
        """
        if isinstance(time_ms, datetime.timedelta):
            ms = int(time_ms.microseconds / 1000)
            time_ms = (time_ms.seconds + time_ms.days * 24 * 3600) * 1000 + ms
        return self.execute_command('PSETEX', name, time_ms, value) 
开发者ID:leancloud,项目名称:satori,代码行数:12,代码来源:client.py

示例9: setex

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def setex(self, name, time, value):
        """
        Set the value of key ``name`` to ``value`` that expires in ``time``
        seconds. ``time`` can be represented by an integer or a Python
        timedelta object.
        """
        if isinstance(time, datetime.timedelta):
            time = time.seconds + time.days * 24 * 3600
        return self.execute_command('SETEX', name, time, value) 
开发者ID:leancloud,项目名称:satori,代码行数:11,代码来源:client.py

示例10: ttl

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def ttl(self, name):
        "Returns the number of seconds until the key ``name`` will expire"
        return self.execute_command('TTL', name) 
开发者ID:leancloud,项目名称:satori,代码行数:5,代码来源:client.py

示例11: brpoplpush

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def brpoplpush(self, src, dst, timeout=0):
        """
        Pop a value off the tail of ``src``, push it on the head of ``dst``
        and then return it.

        This command blocks until a value is in ``src`` or until ``timeout``
        seconds elapse, whichever is first. A ``timeout`` value of 0 blocks
        forever.
        """
        if timeout is None:
            timeout = 0
        return self.execute_command('BRPOPLPUSH', src, dst, timeout) 
开发者ID:leancloud,项目名称:satori,代码行数:14,代码来源:client.py

示例12: get_message

# 需要导入模块: import time [as 别名]
# 或者: from time import seconds [as 别名]
def get_message(self, ignore_subscribe_messages=False, timeout=0):
        """
        Get the next message if one is available, otherwise None.

        If timeout is specified, the system will wait for `timeout` seconds
        before returning. Timeout should be specified as a floating point
        number.
        """
        response = self.parse_response(block=False, timeout=timeout)
        if response:
            return self.handle_message(response, ignore_subscribe_messages)
        return None 
开发者ID:leancloud,项目名称:satori,代码行数:14,代码来源:client.py


注:本文中的time.seconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。