template string template('---$key ---$key ---'template substitute(vals'---spam---shrubbery---template substitute(key ='brian'key ='loretta''---brian---loretta---see the library manual for more on this extension although the string datatype does not itself support the pattern-directed text processing that we'll meet later in this its tools are powerful enough for many tasks parsing with splits and joins in terms of this main focuspython' built-in tools for splitting and joining strings around tokens turn out to be especially useful when it comes to parsing textstr split(delimiter?maxsplits?splits string into list of substringsusing either whitespace (tabsspacesnewlinesor an explicitly passed string as delimiter maxsplits limits the number of splits performedif passed delimiter join(iterableconcatenates sequence or other iterable of substrings ( listtuplegenerator)adding the subject separator string between each these two are among the most powerful of string methods as we saw in split chops string into list of substrings and join puts them back together' dsplit([' '' '' '' '' + + +dsplit('+'[' '' '' '' ''--join([' '' '' ']' -- --cdespite their simplicitythey can handle surprisingly complex text-parsing tasks moreoverstring method calls are very fast because they are implemented in language code for instanceto quickly replace all tabs in file with four periodspipe the file into script that looks like thisfrom sys import stdout write(( join(stdin read(split('\ '))the split call here divides input around tabsand the join puts it back together with periods where tabs had been in this casethe combination of the two calls is equivalent to using the simpler global replacement string method call as followsstdout write(stdin read(replace('\ ' )as we'll see in the next sectionsplitting strings is sufficient for many text-parsing goals string method utilities