data types the third example builds on the previous twoand adds the sign character to force the output of the sign in python decimal decimal numbers are treated by str format(as strings rather than as numbers this makes it quite tricky to get nicely formatted output from python decimal decimal numbers can be formatted as floatsincluding support for to get comma-separated groups here is an example--we have omitted the field name since we don' need it for python "{: }format(decimal decimal(" ")' , , , if we omitted the format character (or used the format character)the number would be formatted as ' + python does not provide any direct support for formatting complex numbers--support was added with python howeverwe can easily solve this by formatting the real and imaginary parts as individual floating-point numbers for example"{ real }{ imag: }jformat( + ' + "{ real }{ imag: }jformat jwe access each attribute of the complex number individuallyand format them both as floating-point numbersin this case with three digits after the decimal place we have also forced the sign to be output for the imaginary partwe must add on the ourselves python supports formatting complex numbers using the same syntax as for floats"{: }format( ee ' , ,, , jone slight drawback of this approach is that exactly the same formatting is applied to both the real and the imaginary partsbut we can always use the python technique of accessing the complex number' attributes individually if we want to format each one differently exampleprint_unicode py in the preceding subsubsections we closely examined the str format(method' format specificationsand we have seen many code snippets that show particular aspects in this subsubsection we will review small yet useful example that makes use of str format(so that we can see format specifications in