Python 2.7.12rc1 (v2.7.12rc1:13912cd1e7e8, june, 05:57:31) [MSC v.1500 64bit (AMD64)] on Win32type"Copyright","credits" or "License ()" formore Information.>>> str1="I love fish">>> Str1[:6]'I love'>>> str="111eee">>>str.isalnum () True>>> str6="I love CPPC">>>Str'111eee'>>>STR6'I love CPPC'>>>str6.splice () Traceback (most recent): File"<pyshell#7>", Line 1,inch<module>str6.splice () attributeerror:'Str'object has no attribute'Splice'>>>str6.split () ['I',' love','CPPC']>>>STR6'I love CPPC'>>>Str6.title ()'I Love Cppc'>>>"{a} Love {b}. {c}". Format (a='I', b='Fish', c='com')'I love fish.com'>>> {0}.format ("ni") Traceback (most recent): File"<pyshell#12>", Line 1,inch<module>{0}.format ("ni") Attributeerror:'Set'object has no attribute'format'>>>"{0}". Format ("ni")'ni'>>> {{0}}.format ("ni") Traceback (most recent): File"<pyshell#14>", Line 1,inch<module>{{0}}.format ("ni") typeerror:unhashable type:'Set'>>>"{{0}}". Format ("ni") File"<pyshell#15>", Line 2"{{0}}". Format ("ni") ^indentationerror:unexpected Indent>>>"{}". Format ("ni")'ni'>>>"{{0}}". Format ("ni")'{0}'>>>"{0:.1lf}{1}". Format (27.546, GB) Traceback (most recent): File"<pyshell#18>", Line 1,inch<module>"{0:.1lf}{1}". Format (27.546, GB) Nameerror:name'GB' is notdefined>>>"{0:.1lf}{1}". Format ('27.546','GB') Traceback (most recent): File"<pyshell#19>", Line 1,inch<module>"{0:.1lf}{1}". Format ('27.546','GB') valueerror:invalid Conversion Specification>>>"{0:.1lf}{1}". Format (27.546,'GB') Traceback (most recent): File"<pyshell#20>", Line 1,inch<module>"{0:.1lf}{1}". Format (27.546,'GB') valueerror:invalid Conversion Specification>>>"{0:.1f}{1}". Format ('27.546','GB') Traceback (most recent): File"<pyshell#21>", Line 1,inch<module>"{0:.1f}{1}". Format ('27.546','GB') valueerror:unknown Format Code'F' forObject of type'Str'>>>'{0:.1lf}{1}'. Format (27.546,'GB') Traceback (most recent): File"<pyshell#22>", Line 1,inch<module>'{0:.1lf}{1}'. Format (27.546,'GB') valueerror:invalid Conversion Specification>>>"{0:.lf}{1}". Format (27.546,'GB') Traceback (most recent): File"<pyshell#23>", Line 1,inch<module>"{0:.lf}{1}". Format (27.546,'GB') Valueerror:format specifier missing precision>>>"{0:.1f}{1}". Format (27.546,'GB')'27.5GB'>>>'%c%c%c'% (97,97,99)'a A C'>>>'%e'% 27.3342'2.733420e+01'>>>
Python string formatting