python_tool_yhz/pil_yz.py
def byte(number):
    """Return the given bytes as a human friendly KB, MB, GB, or TB string"""
    B = float(number)
    KB = float(1024)  # 1024 b,  1 千字节=1024 字节
    MB = float(KB ** 2)  # 1024 kb, 1 兆字节=1048576 字节
    GB = float(KB ** 3)  # 1024 mb, 1 千兆字节(GB)=1073741824 字节(B)
    TB = float(KB ** 4)  # 1024 gb
    c = color_yz.color()

    if B < KB:
        return c.okgreen(f"{round(B, ndigits=2)} Bytes")
    elif KB <= B < MB:
        return c.okgreen(f"{round(B / KB, ndigits=2)} KB")
    elif MB <= B < GB:
        return c.okgreen(f"{round(B / MB, ndigits=2)} MB")
    elif GB <= B < TB:
        return c.okgreen(f"{round(B / GB, ndigits=2)} GB")
    elif TB <= B:
        return c.okgreen(f"{round(B / TB, ndigits=2)} TB")
Return the given bytes as a human friendly KB, MB, GB, or TB string
Return the given bytes as a human friendly KB, MB, GB, or TB string
Return the given bytes as a human friendly KB MB GB or TB string
def byte(number):
    B = float(number)
    KB = float(1024)  
    MB = float(KB ** 2)  
    GB = float(KB ** 3)  
    TB = float(KB ** 4)  
    c = color_yz.color()
    if B < KB:
        return c.okgreen(f"{round(B, ndigits=2)} Bytes")
    elif KB <= B < MB:
        return c.okgreen(f"{round(B / KB, ndigits=2)} KB")
    elif MB <= B < GB:
        return c.okgreen(f"{round(B / MB, ndigits=2)} MB")
    elif GB <= B < TB:
        return c.okgreen(f"{round(B / GB, ndigits=2)} GB")
    elif TB <= B:
        return c.okgreen(f"{round(B / TB, ndigits=2)} TB")
def byte ( number ) : B = float ( number ) KB = float ( 1024 ) MB = float ( KB ** 2 ) GB = float ( KB ** 3 ) TB = float ( KB ** 4 ) c = color_yz . color ( ) if B < KB : return c . okgreen ( f"{round(B, ndigits=2)} Bytes" ) elif KB <= B < MB : return c . okgreen ( f"{round(B / KB, ndigits=2)} KB" ) elif MB <= B < GB : return c . okgreen ( f"{round(B / MB, ndigits=2)} MB" ) elif GB <= B < TB : return c . okgreen ( f"{round(B / GB, ndigits=2)} GB" ) elif TB <= B : return c . okgreen ( f"{round(B / TB, ndigits=2)} TB" )
Return the given bytes as a human friendly KB, MB, GB, or TB string
Return the given bytes as a human friendly KB MB GB or TB string
"""Return the given bytes as a human friendly KB, MB, GB, or TB string""" # 1024 b,  1 千字节=1024 字节 # 1024 kb, 1 兆字节=1048576 字节 # 1024 mb, 1 千兆字节(GB)=1073741824 字节(B) # 1024 gb
number