python 2.7.12rc1 (v2.7.12rc1:13912cd1e7e8, jun 12 2016, 05:57:31) [MSC v.1500 64 bit (AMD64)] on win32type "copyright", "credits" or "license ()" for more information.>>> str1= "I love fish" >> > str1[:6] ' i love ' >>> str= "111eee" >>> str.isalnum () True>>> str6= "I&NBSP;LOVE&NBSP;CPPC" >>> str ' 111eee ' >>> str6 ' I&NBSP;LOVE&NBSP;CPPC ' >>> str6.splice () traceback (most recent call last): File " <pyshell#7> ", line 1, in <module> str6.splice () attributeerror: ' str ' object has no attribute ' splice ' >>> Str6.split () [' I ', ' love ', ' cppc ']>>> str6 ' I&NBSP;LOVE&NBSP;CPPC ' >>> Str6.title () ' I&NBSP;LOVE&NBSP;CPPC ' >>> "{a} love {b}. {c} ". Format (a= ' i ', b= ' fish ', c= ' com ') ' i love fish.com ' >>> {0}.format (" ni ") Traceback (most recent call last): file "<pyshell#12>", line 1, in <module> {0}.format ("ni") attributeerror: ' Set ' object has no attribute ' format ' >>> ' {0} '. Format ("ni") ' Ni ' >>> {{0}}. Format ("Ni") traceback (most recent call last): file "<pyshell#14>", line 1, in <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 call last ): file "<pyshell#18>", line 1, in <module> "{0:.1lf}{1}". Format (27.546,GB) nameerror: name ' GB ' is not defined>>> "{0:.1lf}{1}". Format (' 27.546 ', ' GB ') traceback (most recent call last): file "<pyshell#19>", line 1, in <module> "{0:.1LF} {1} ". Format (' 27.546 ', ' GB ') valueerror: invalid conversion specification>>> " {0:. 1lf}{1} ". Format (27.546, ' GB ') traceback (most recent call last): file " < Pyshell#20> ", line 1, in <module> " {0:.1lf}{1} ". Format ( 27.546, ' GB ') valueerror: invalid conversion specification>>> ' {0:.1f}{1} '. Format (' 27.546 ', ' GB ') Traceback (most recent call last): file "<pyshell#21>", line 1, in <module> "{0:.1f}{1}". Format (' 27.546 ', ' GB ') valueerror: unknown format code ' F ' for object of type ' str ' >>> ' {0:.1lf}{1 } '. Format (27.546, ' GB ') traceback (most recent call last): file "<pyshell #22 > ", line 1, in <module> ' {0:.1lf}{1} '. Format (27.546, ' GB ') valueerror: invalid conversion specification>>> "{0:.lf}{1}". Format (27.546, ' GB ') ) traceback (most recent call last): file "<pyshell#23>", line 1, in <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 ' >>>
650) this.width=650; "src="/img/fz.gif "alt=" Copy Code "style=" Margin:0px;padding:0px;border:none; "/>
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/730879/201611/730879-20161109000826483-1186935592. PNG "style=" margin:0px;padding:0px;border:0px; "/>
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/730879/201611/730879-20161109000807889-515814846. PNG "style=" margin:0px;padding:0px;border:0px; "/>
650) this.width=650; "Src=" http://images2015.cnblogs.com/blog/730879/201611/730879-20161109000818202-1297277783. PNG "style=" margin:0px;padding:0px;border:0px; "/>
Python string formatting