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.

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} {name} !")
s = s.geetools.format({"greeting": "Hello", "name": "bob"})
s.getInfo()
'Hello bob !'