string and text handling template contains the original strings passed to template(the behavior of the template class can be modified by subclassing it and redefining the attributes delimiter and idpattern for examplethis code changes the escape character to and restricts key names to letters onlyclass mytemplate(string template)delimiter '@literal character for escape sequence idpattern '[ - ]*identifier regular expression pattern utility functions the string module also defines couple of functions for manipulating strings that aren' defined as method on string objects capwords(scapitalizes the first letter of each word in sreplaces repeated whitespace characters with single spaceand removes leading and trailing whitespace maketrans(fromtocreates translation table that maps each character in from to the character in the same position in to from and to must be the same length this function is used to create arguments suitable for use with the translate(method of strings struct the struct module is used to convert data between python and binary data structures (represented as python byte stringsthese data structures are often used when interacting with functions written in cbinary file formatsnetwork protocolsor binary communication over serial ports packing and unpacking functions the following module-level functions are used to pack and unpack data in byte strings if your program is repeatedly performing these operationsconsider the use of struct object described in the next section pack(fmtv packs the values and so on into byte string according to the format string in fmt pack_into(fmtbufferoffsetv packs the values and so forth into writable buffer object buffer starting at byte offset offset this only works with objects that support the buffer interface examples include array array and bytearray objects unpack(fmtstringunpacks the contents of byte string according to the format string in fmt returns tuple of the unpacked values the length of string must exactly match the size of the format as determined by the calcsize(function lib fl ff