首页 > 代码库 > python出输出字符串方式:

python出输出字符串方式:

python出输出字符串方式:

>>> who=‘knights‘

>>> what=‘NI‘

>>> print (‘we are the‘,who,‘wha say‘,what,what,what,what)

we are the knights wha say NI NI NI NI

>>> print (‘we are the %s who say %s‘% (who,(what+‘ ‘)*4))

we are the knights who say NI NI NI NI

>>>

python数字循环

>>> for item in [0,1,2]:

 print (item)

0

1

2

>>> for item in range(3):

 print (item)

0

1

2

>>>

>>> for item in range(3):

 print (item)

0

1

2

>>> foo=‘abc‘

>>> for i in range(len(foo)):

 print (foo[i],‘%d‘% i)

a 0

b 1

c 2

>>>

python出输出字符串方式: