Discuss / Python / daka

雅乐landa

#1 Created at ... [Delete] [Delete and Lock User]

list = ['Michael', 'Bob', 'Tracy']

for i in list:

    print('Hello, %s!'%i)

木须炒面

#2 Created at ... [Delete] [Delete and Lock User]

print('Hello, %s!'%i)

请问'!'是代表什么??

Kitaoo

#3 Created at ... [Delete] [Delete and Lock User]

字符串格式化,使用%s做占位符,实际值为i

木须炒面

#4 Created at ... [Delete] [Delete and Lock User]

恍然大悟!谢谢,原来是这样,我以为!是什么特殊符号,原来就是叹号。。。

欲何732016

#5 Created at ... [Delete] [Delete and Lock User]

貌似直接

L = ['Bart', 'Lisa', 'Adam']n=0while n<=2:  a=L[n]  n = n + 1
  print(a)

更简单  只是不知道有没有什么风险

欲何732016

#6 Created at ... [Delete] [Delete and Lock User]

啊  我懂了 上面那句话党委没说  重要的是下面的

L = ['Bart', 'Lisa', 'Adam']n=0while n<=2:  a=L[n]  n = n + 1  print('helo %a'%a)

如果是这样  输出的是

helo 'Bart'

helo 'Lisa'

helo 'Adam'

a%和s%什么区别


  • 1

Reply