def format_time(seconds, n=5):
    """Format seconds to std time.
    note:
    Args:
        seconds (int): seconds.
        n:precision (D,h,m,s,ms)
    Returns:
        str: .
    Example:
        seconds = 123456.7
        format_time(seconds)
        #output
        1D10h17m36s700ms
        format_time(seconds, n=2)
        #output
        1D10h
    """
    days = int(seconds / 3600/ 24)
    seconds = seconds - days * 3600 * 24
    hours = int(seconds / 3600)
    seconds = seconds - hours * 3600
    minutes = int(seconds / 60)
    seconds = seconds - minutes * 60
    secondsf = int(seconds)
    seconds = seconds - secondsf
    millis = round(seconds * 1000)

    f = ''
    i = 1
    if days > 0:
        f += str(days) + 'D'
        i += 1
    if hours > 0 and i <= n:
        f += str(hours) + 'h'
        i += 1
    if minutes > 0 and i <= n:
        f += str(minutes) + 'm'
        i += 1
    if secondsf > 0 and i <= n:
        f += str(secondsf) + 's'
        i += 1
    if millis > 0 and i <= n:
        f += str(millis) + 'ms'
        i += 1
    if f == '':
        f = '0ms'
    return f