def format_string(format_config, target_value):
    """
    Formats number, supporting %-format and str.format() syntax.

    :param format_config: string format syntax, for example '{:.2%}' or '%.2f'
    :param target_value: number to format
    :rtype: string
    """
    if (format_config.startswith('{')):
        return format_config.format(target_value)
    else:
        return format_config % (target_value)