當前位置: 首頁>>代碼示例>>Python>>正文


Python moves.zip_longest方法代碼示例

本文整理匯總了Python中pip._vendor.six.moves.zip_longest方法的典型用法代碼示例。如果您正苦於以下問題:Python moves.zip_longest方法的具體用法?Python moves.zip_longest怎麽用?Python moves.zip_longest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip._vendor.six.moves的用法示例。


在下文中一共展示了moves.zip_longest方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: tabulate

# 需要導入模塊: from pip._vendor.six import moves [as 別名]
# 或者: from pip._vendor.six.moves import zip_longest [as 別名]
def tabulate(vals):
    # From pfmoore on GitHub:
    # https://github.com/pypa/pip/issues/3651#issuecomment-216932564
    assert len(vals) > 0

    sizes = [0] * max(len(x) for x in vals)
    for row in vals:
        sizes = [max(s, len(str(c))) for s, c in zip_longest(sizes, row)]

    result = []
    for row in vals:
        display = " ".join([str(c).ljust(s) if c is not None else ''
                            for s, c in zip_longest(sizes, row)])
        result.append(display)

    return result, sizes 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:18,代碼來源:list.py

示例2: tabulate

# 需要導入模塊: from pip._vendor.six import moves [as 別名]
# 或者: from pip._vendor.six.moves import zip_longest [as 別名]
def tabulate(rows):
    # type: (Iterable[Iterable[Any]]) -> Tuple[List[str], List[int]]
    """Return a list of formatted rows and a list of column sizes.

    For example::

    >>> tabulate([['foobar', 2000], [0xdeadbeef]])
    (['foobar     2000', '3735928559'], [10, 4])
    """
    rows = [tuple(map(str, row)) for row in rows]
    sizes = [max(map(len, col)) for col in zip_longest(*rows, fillvalue='')]
    table = [" ".join(map(str.ljust, row, sizes)).rstrip() for row in rows]
    return table, sizes 
開發者ID:ali5h,項目名稱:rules_pip,代碼行數:15,代碼來源:misc.py


注:本文中的pip._vendor.six.moves.zip_longest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。