format#

geetools.ee_string.StringAccessor.format(template)#

Format a string with a dictionary.

Replace the keys in the string using the values provided in the dictionary. Follow the same pattern: value format as Python string.format method.

Numbers and Dates can be formatted using formatters:
Parameters:

template (dict | ee.Dictionary) – A dictionary with the values to replace.

Returns:

The formatted string.

Return type:

ee.String

Examples

import ee, geetools
from geetools.utils import initialize_documentation

initialize_documentation()

s = ee.String("{greeting} developer, pi={number%.2f} start={start%tyyyy-MM-dd} end={end%tdd MMM yyyy}")
s = s.geetools.format({"greeting": "Hello", "number": 3.1415, "start": 1577836800000, "end": "2021-01-01"})
s.getInfo()
'Hello developer, pi=3.14 start=2020-01-01 end=01 Jan 2021'