L = ['Bart', 'Lisa', 'Adam'] for name in L: print('Hello,'+name+'!')
n=0 while n<3: print('Hello,'+L[n]+'!') n=n+1
n=0 while n<3: print('Hello,%s!'%L[n]) n=n+1
为什么第一种方法是print('Hello,', +name+'!') 而不是print('Hello,', name'!') 谢谢您!
啊已经明白了 谢谢
为什么要加+?
自己试试 不加和 加上 的结果 就知道了为什么了
Sign in to make a reply
小甜甜郑林200
L = ['Bart', 'Lisa', 'Adam'] for name in L: print('Hello,'+name+'!')
n=0 while n<3: print('Hello,'+L[n]+'!') n=n+1
n=0 while n<3: print('Hello,%s!'%L[n]) n=n+1