Suzy云
下决心容易,做起来难,坚持做难上加难.. 是否真的那么难?不试试怎么知道?

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

>>>

posted on 2015-01-31 18:29  Suzy云  阅读(413)  评论(0编辑  收藏  举报